import re from q20 import load_file pattern = r"^\{\{基礎情報.*?$(.*?)^\}\}$" repattern = re.compile(pattern, re.MULTILINE + re.VERBOSE + re.DOTALL) match = repattern.findall(load_file()) pat = r"^\|(.+?) = (.+?)\n" repat = re.compile(pat, re.MULTILINE + re.VERBOSE + re.DOTALL) match1 = repat.findall(match[0]) dic = {m[0]: m[1] for m in match1} print(dic)
import re from q20 import load_file split_text = load_file().splitlines() pattern = r"\[\[Category:(.*?)\]\]" repattern = re.compile(pattern) for t in split_text: match = repattern.match(t) if match: print(match[1])