Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a6de52c7
Commit
a6de52c7
authored
Apr 17, 2019
by
josh
Committed by
Brett Cannon
Apr 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32913: Added re.Match.groupdict example to regex HOWTO (GH-5821)
parent
4c3efd9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
0 deletions
+8
-0
Doc/howto/regex.rst
Doc/howto/regex.rst
+7
-0
Misc/NEWS.d/next/Documentation/2018-02-22-15-48-16.bpo-32913.f3utho.rst
...xt/Documentation/2018-02-22-15-48-16.bpo-32913.f3utho.rst
+1
-0
No files found.
Doc/howto/regex.rst
View file @
a6de52c7
...
...
@@ -942,6 +942,13 @@ given numbers, so you can retrieve information about a group in two ways::
>>> m.group(1)
'Lots'
Additionally, you can retrieve named groups as a dictionary with
:meth:`~re.Match.groupdict`::
>>> m = re.match(r'(?P
<first>
\w+) (?P
<last>
\w+)', 'Jane Doe')
>>> m.groupdict()
{'first': 'Jane', 'last': 'Doe'}
Named groups are handy because they let you use easily-remembered names, instead
of having to remember numbers. Here's an example RE from the :mod:`imaplib`
module::
...
...
Misc/NEWS.d/next/Documentation/2018-02-22-15-48-16.bpo-32913.f3utho.rst
0 → 100644
View file @
a6de52c7
Added re.Match.groupdict example to regex HOWTO.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment