123456789101112131415 |
- import re
- case_pattern = re.compile(r"case\s(?P<name>[^:]*):\s*.*?new GUIContent\((?P<val>\"[^\"]*\")\);")
- name_pattern = re.compile(r"\{(?P<key>[^,]*),\s(?P<tmp>\d*)\}")
- with open("input.txt", "r", encoding="utf-8") as f:
- with open("result.txt", "w", encoding="utf-8") as fo:
- helper = {}
- t = f.read()
- for m in name_pattern.finditer(t):
- helper[m.group("tmp")] = m.group("key")
- for m in case_pattern.finditer(t):
- k = helper[m.group("name")]
- fo.write(f"[{k}] = {m.group('val')},\n")
|