f | import re | f | import re |
| | | |
n | p = input() | n | reTemplate = input() |
| | | |
| inputStr = input() | | inputStr = input() |
| | | |
| while inputStr != "": | | while inputStr != "": |
n | res = re.search(p, inputStr) | n | res = re.search(reTemplate, inputStr) |
| if res: | | if res: |
t | k = res.group() | t | tmp = res.group() |
| print(f"{res.start()}: {k}") | | print(f"{res.start()}: {tmp}") |
| for idx, group in enumerate(res.groups()): | | for idx, group in enumerate(res.groups()): |
| if not group: | | if not group: |
| continue | | continue |
| print(f"{idx+1}/{res.start(idx+1)}: {group}") | | print(f"{idx+1}/{res.start(idx+1)}: {group}") |
| grDict = res.groupdict() | | grDict = res.groupdict() |
| for name in grDict: | | for name in grDict: |
| group = grDict[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() |
| | | |