Skip to content
Snippets Groups Projects
Unverified Commit 48647d00 authored by Miss Islington (bot)'s avatar Miss Islington (bot) Committed by GitHub
Browse files

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


(cherry picked from commit 642d1fa8)

Co-authored-by: default avatarBaptiste Mispelon <bmispelon@gmail.com>
parent 36374251
No related branches found
No related tags found
No related merge requests found
...@@ -1324,6 +1324,14 @@ Match objects support the following methods and attributes: ...@@ -1324,6 +1324,14 @@ Match objects support the following methods and attributes:
>>> m[2] # The second parenthesized subgroup. >>> m[2] # The second parenthesized subgroup.
'Newton' '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 .. versionadded:: 3.6
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment