[Python-checkins] cpython (merge 3.5 -> default): #25517: merge with 3.5.

ezio.melotti python-checkins at python.org
Mon Jan 11 17:11:40 EST 2016


https://hg.python.org/cpython/rev/48e2f5915d49
changeset:   99866:48e2f5915d49
parent:      99862:cb08e5271cc0
parent:      99865:6bd4a4907f66
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Tue Jan 12 00:09:43 2016 +0200
summary:
  #25517: merge with 3.5.

files:
  Doc/howto/regex.rst |  7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)


diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -1004,17 +1004,18 @@
 
 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

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list