Upon reading the python regex module, (?P<name>...)
usually confused me.
I knew P
here stanrds for nothing but random things as foo
bar
zoo
from the answer python - Named regular expression group "(?Pregexp)": what does "P" stand for? - Stack Overflow
(?P<name>...)
Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. Group names must be valid Python identifiers, and each group name must be defined only once within a regular expression. A symbolic group is also a numbered group, just as if the group were not named.
Named groups can be referenced in three contexts. If the pattern is (?P['"]).*?(?P=quote) (i.e. matching a string quoted with either single or double quotes):
Mistakes often make in repl argument in re.sub
to employ \g<quote>
.
Since I try to be pythonic and explain the root things to others.
why use g instead of p in \g<quote>
or why not use G in (?P<name>...)
?
so there will be some consistent than chaos.