Skip to content Skip to sidebar Skip to footer

Python Re.findall With Groupdicts

I kind of wish that there were a version of re.findall that returned groupdicts instead of just groups. Am I missing some simple way to accomplish the same result? (Does anybody kn

Solution 1:

You could use the finditer() function. This will give you a sequence of match objects, so you can get the groupdict for each with:

[m.groupdict() for m in regex.finditer(search_string)]

Post a Comment for "Python Re.findall With Groupdicts"