8000 [3.14] Docs: Add missing lines between regex and text (GH-134505) (GH… · python/cpython@a7abb8c · GitHub
[go: up one dir, main page]

Skip to content

Commit a7abb8c

Browse files
[3.14] Docs: Add missing lines between regex and text (GH-134505) (GH-135718)
Docs: Add missing lines between regex and text (GH-134505) (cherry picked from commit 7541902) Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>
1 parent 250bb7f commit a7abb8c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Doc/howto/regex.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,9 @@ extension. This regular expression matches ``foo.bar`` and
10161016
Now, consider complicating the problem a bit; what if you want to match
10171017
filenames where the extension is not ``bat``? Some incorrect attempts:
10181018

1019-
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring
1019+
``.*[.][^b].*$``
1020+
1021+
The first attempt above tries to exclude ``bat`` by requiring
10201022
that the first character of the extension is not a ``b``. This is wrong,
10211023
because the pattern also doesn't match ``foo.bar``.
10221024

@@ -1043,7 +1045,9 @@ confusing.
10431045

10441046
A negative lookahead cuts through all this confusion:
10451047

1046-
``.*[.](?!bat$)[^.]*$`` The negative lookahead means: if the expression ``bat``
1048+
``.*[.](?!bat$)[^.]*$``
1049+
1050+
The negative lookahead means: if the expression ``bat``
10471051
doesn't match at this point, try the rest of the pattern; if ``bat$`` does
10481052
match, the whole pattern will fail. The trailing ``$`` is required to ensure
10491053
that something like ``sample.batch``, where the extension only starts with

0 commit comments

Comments
 (0)
0