2024-01-01から1年間の記事一覧

コメント除去 + 関数リストアップ const fs = require('fs'); const path = require('path'); function removeComments(code) { const lines = code.split(/(?マルチラインコメントモード if (char === '*' && line[i + 1] === '/') { // 終端検出 inMultili…

コメント除去 function removeComments(code) { const lines = code.split(/(?マルチラインコメントモード if (char === '*' && line[i + 1] === '/') { // 終端検出 inMultilineComment = false; i++; // /ぶんをスキップ } else if (char === '\n') { // …

import re def split_data(input_str): pattern = r"(\d+?)\s*:(.*?)[,\s]" results = [] for match in re.finditer(pattern, input_str): num = match.group(1) data = match.group(2) results.append((num, data)) return results # 使用例 input_str = "0…

python学習

import lxml.etree as etree # 追加・更新関数 class PathManipulator: @staticmethod def custom_split(xpath, sep='/'): result = [] in_quotes = False start = 0 for i, char in enumerate(xpath): if char in ('"', "'"): in_quotes = not in_quotes el…