2024-03-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…