f | import re | f | import re |
| | | |
n | template = input() | n | reTemplate = input() |
| | | inputStr = input() |
| | | |
n | inputStr = input() | n | |
| while inputStr != "": | | while inputStr != "": |
n | res = re.search(template, inputStr) | n | res = re.search(reTemplate, inputStr) |
| if res: | | if res: |
n | buf = res.group() | n | tmp = res.group() |
| print(f"{res.start()}: {buf}") | | print(f"{res.start()}: {tmp}") |
| for index, group in enumerate(res.groups()): | | for idx, group in enumerate(res.groups()): |
| if not group: | | if not group: |
| continue | | continue |
t | print(f"{index+1}/{res.start(index+1)}: {group}") | t | print(f"{idx+1}/{res.start(idx+1)}: {group}") |
| groupDict = res.groupdict() | | grDict = res.groupdict() |
| for name in groupDict: | | for name in grDict: |
| group = groupDict[name] | | group = grDict[name] |
| if not group: | | if not group: |
| continue | | continue |
| print(f"{name}/{res.start(name)}: {group}") | | print(f"{name}/{res.start(name)}: {group}") |
| else: | | else: |
| print("<NONE>") | | print("<NONE>") |
| inputStr = input() | | inputStr = input() |
| | | |