Named Groups
While numbered groups are useful, keeping track of group numbers can become difficult in complex regular expressions. Named groups allow you to assign a specific name to a capturing group, making your patterns more readable and your code easier to maintain.
Syntax
To create a named group, use the syntax (?P<name>...), where name is the identifier you want to use.