From: Ezio Melotti <ezio.melotti@gmail.com>
Date: Mon, 11 Jan 2016 22:09:13 +0000 (+0200)
Subject: #25517: fix regex in the regex howto.  Patch by Elena Oat.
X-Git-Tag: v3.6.0a1~790^2
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84c63e8df4f48a34ad20829125c12db71314f9ef;p=python

#25517: fix regex in the regex howto.  Patch by Elena Oat.
---

diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index ad2c6ab7d5..70721a9f27 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -1004,17 +1004,18 @@ confusing.
 
 A negative lookahead cuts through all this confusion:
 
-``.*[.](?!bat$).*$``  The negative lookahead means: if the expression ``bat``
+``.*[.](?!bat$)[^.]*$``  The negative lookahead means: if the expression ``bat``
 doesn't match at this point, try the rest of the pattern; if ``bat$`` does
 match, the whole pattern will fail.  The trailing ``$`` is required to ensure
 that something like ``sample.batch``, where the extension only starts with
-``bat``, will be allowed.
+``bat``, will be allowed.  The ``[^.]*`` makes sure that the pattern works
+when there are multiple dots in the filename.
 
 Excluding another filename extension is now easy; simply add it as an
 alternative inside the assertion.  The following pattern excludes filenames that
 end in either ``bat`` or ``exe``:
 
-``.*[.](?!bat$|exe$).*$``
+``.*[.](?!bat$|exe$)[^.]*$``
 
 
 Modifying Strings