f | import re | f | import re |
n | regex = input() | n | pattern = input() |
| while (s := input()): | | while (line := input()): |
| res = re.search(regex, s) | | match = re.search(pattern, line) |
| if res is None: | | if match is None: |
| print('<NONE>') | | print('<NONE>') |
| else: | | else: |
t | print(f'{res.start()}: {res.group()}') | t | print(f'{match.start()}: {match.group()}') |
| for i, gr in enumerate(res.groups()): | | for idx, sub in enumerate(match.groups()): |
| if gr: | | if sub: |
| print(f'{i + 1}/{res.start(i + 1)}: {gr}') | | print(f'{idx + 1}/{match.start(idx + 1)}: {sub}') |
| for name, gr in res.groupdict().items(): | | for name, sub in match.groupdict().items(): |
| if gr: | | if sub: |
| print(f'{name}/{res.start(name)}: {gr}') | | print(f'{name}/{match.start(name)}: {sub}') |