diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 22:09:43 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2016-01-11 22:09:43 (GMT) |
commit | 1d377712927c957c38f2a4fa96d61b7eb0e0dbca (patch) | |
tree | 3fa0b4a33442da929a2d06be33e562566e494532 | |
parent | d4d4f20284a098f4bad2958d5a72cfd9033f8b08 (diff) | |
parent | 84c63e8df4f48a34ad20829125c12db71314f9ef (diff) | |
download | cpython-1d377712927c957c38f2a4fa96d61b7eb0e0dbca.zip cpython-1d377712927c957c38f2a4fa96d61b7eb0e0dbca.tar.gz cpython-1d377712927c957c38f2a4fa96d61b7eb0e0dbca.tar.bz2 |
#25517: merge with 3.5.
-rw-r--r-- | Doc/howto/regex.rst | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index ad2c6ab..70721a9 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 |