Support named capture groups in regex transformers (#94)

This commit is contained in:
Mr. Pine 2024-10-21 15:21:33 +02:00 committed by GitHub
parent 19beb8f07b
commit 4f9e2ab48d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -110,6 +110,10 @@ class ExactReTf(Transformation):
except ValueError:
pass
named_groups: Dict[str, str] = match.groupdict()
for name, capture in named_groups.items():
locals_dir[name] = capture
result = eval(f"f{right!r}", {}, locals_dir)
return Transformed(PurePath(result))