Skip to content

Commit 39b89c3

Browse files
committed
Merge branch 'update-regex-howto' of github.com:akuchling/cpython into update-regex-howto
2 parents 05c04ec + 4752488 commit 39b89c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Doc/howto/regex.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,14 @@ The syntax for a named group is one of the Python-specific extensions:
989989
``(?P<name>...)``. Named groups behave exactly like capturing groups, and
990990
additionally associate *name* with the group so that *name* can be used to
991991
refer to the group in other contexts. Names should look like a Python
992-
identifier andonly contain letters, digits and underscores. The :ref:`match
992+
identifier and only contain letters, digits and underscores. The :ref:`match
993993
object <match-objects>` methods that deal with capturing groups all accept
994994
either integers that refer to the group by number or strings that contain the
995995
desired group's name. Named groups are still given numbers, so you can
996996
retrieve information about a group in two ways::
997997

998998
>>> p = re.compile(r'(?P<word>\b\w+\b)')
999-
>>> m = p.search( '((( Lots of punctuation )))' )
999+
>>> m = p.search('((( Lots of punctuation )))')
10001000
>>> m.group('word')
10011001
'Lots'
10021002
>>> m.group(1)
@@ -1022,8 +1022,8 @@ module::
10221022
r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
10231023
r'"')
10241024

1025-
It's much easier to write ``m.group('zonem')``, instead of having
1026-
to remember to retrieve group 9.
1025+
It's much easier to write ``m.group('zonem')`` instead of having
1026+
to count groups so as to verify we must retrieve group 9.
10271027

10281028
The syntax for backreferences in an expression such as ``(...)\1`` refers to the
10291029
number of the group. There's naturally a variant that uses the group name

0 commit comments

Comments
 (0)