Skip to content

Commit 2537188

Browse files
[3.13] Docs: Add missing lines between regex and text (pythonGH-134505) (pythonGH-135719)
Docs: Add missing lines between regex and text (pythonGH-134505) (cherry picked from commit 7541902) Co-authored-by: Rafael Fontenelle <[email protected]>
1 parent af48f39 commit 2537188

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
@@ -1013,7 +1013,9 @@ extension. This regular expression matches ``foo.bar`` and
10131013
Now, consider complicating the problem a bit; what if you want to match
10141014
filenames where the extension is not ``bat``? Some incorrect attempts:
10151015

1016-
``.*[.][^b].*$`` The first attempt above tries to exclude ``bat`` by requiring
1016+
``.*[.][^b].*$``
1017+
1018+
The first attempt above tries to exclude ``bat`` by requiring
10171019
that the first character of the extension is not a ``b``. This is wrong,
10181020
because the pattern also doesn't match ``foo.bar``.
10191021

@@ -1040,7 +1042,9 @@ confusing.
10401042

10411043
A negative lookahead cuts through all this confusion:
10421044

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

0 commit comments

Comments
 (0)