In Python, the (?P<group_name>…)
syntax allows one to refer to the matched string through its name:
>>> import re
>>> match = re.search('(?P<name>.*) (?P<phone>.*)', 'John 123456')
>>> match.group('name')
'John'
What does “P” stand for? I could not find any hint in the official documentation.
I would love to get ideas about how to help my students remember this syntax. Knowing what “P” does stand for (or might stand for) would be useful.