I'm searching for a way to apply a regex to a texts and extract its values in the form of a dictionary.
The Groups in the regexes can be named, non-named or mixed.
Ideally, I would use fuzzy matching (Allow some errors in the text).
Text example: Name: foo BaR; Age: 42
Regex Example: Name: (?<name>[a-z]+) (?<lastname>[A-Z]+); Age: (\d+)'
Expected Output: {name: foo, lastname: BaR, gr0: 42}
With the question, I also post my answer below
If there is a better way, I would be happy to take it ;)
Cheers :)
So this is what I use so far.
{e<=3})regex.search(...).capturedict()to extract dict of named-groupsOutput:
{'name': ['foo'], 'lastname': ['BaR'], 'gr0': ['42']}