htmlやxmlなどのテキストファイルから、タグの名前だけを取り出すPythonコードです。例えば、<tagname>~</tagname>のtagnameだけを取り出したいときに使用します。 取り出したい情報は正規表現で探しているので、正規表現を変えれば、ほかの用途でも使えます。 コード: import re def extract_matching_parts(file_path, regex_pattern): with open(file_path, 'r') as file: text = file.read() matches = re.findall(regex_pattern,…