File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1004,17 +1004,18 @@ confusing.
10041004
10051005A negative lookahead cuts through all this confusion:
10061006
1007- ``.*[.](?!bat$). *$ `` The negative lookahead means: if the expression ``bat ``
1007+ ``.*[.](?!bat$)[^.] *$ `` The negative lookahead means: if the expression ``bat ``
10081008doesn't match at this point, try the rest of the pattern; if ``bat$ `` does
10091009match, the whole pattern will fail. The trailing ``$ `` is required to ensure
10101010that something like ``sample.batch ``, where the extension only starts with
1011- ``bat ``, will be allowed.
1011+ ``bat ``, will be allowed. The ``[^.]* `` makes sure that the pattern works
1012+ when there are multiple dots in the filename.
10121013
10131014Excluding another filename extension is now easy; simply add it as an
10141015alternative inside the assertion. The following pattern excludes filenames that
10151016end in either ``bat `` or ``exe ``:
10161017
1017- ``.*[.](?!bat$|exe$). *$ ``
1018+ ``.*[.](?!bat$|exe$)[^.] *$ ``
10181019
10191020
10201021Modifying Strings
You can’t perform that action at this time.
0 commit comments