Skip to content
Snippets Groups Projects
Unverified Commit 642d1fa8 authored by Baptiste Mispelon's avatar Baptiste Mispelon Committed by GitHub
Browse files

gh-92727: Add example of named group in doc for re.Match.__getitem__ (#92730)

parent 7fa9b7da
Branches
Tags
No related merge requests found
......@@ -1327,6 +1327,14 @@ Match objects support the following methods and attributes:
>>> m[2] # The second parenthesized subgroup.
'Newton'
Named groups are supported as well::
>>> m = re.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Isaac Newton")
>>> m['first_name']
'Isaac'
>>> m['last_name']
'Newton'
.. versionadded:: 3.6
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment