File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1004,17 +1004,18 @@ confusing.
1004
1004
1005
1005
A negative lookahead cuts through all this confusion:
1006
1006
1007
- ``.*[.](?!bat$). *$ `` The negative lookahead means: if the expression ``bat ``
1007
+ ``.*[.](?!bat$)[^.] *$ `` The negative lookahead means: if the expression ``bat ``
1008
1008
doesn't match at this point, try the rest of the pattern; if ``bat$ `` does
1009
1009
match, the whole pattern will fail. The trailing ``$ `` is required to ensure
1010
1010
that 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.
1012
1013
1013
1014
Excluding another filename extension is now easy; simply add it as an
1014
1015
alternative inside the assertion. The following pattern excludes filenames that
1015
1016
end in either ``bat `` or ``exe ``:
1016
1017
1017
- ``.*[.](?!bat$|exe$). *$ ``
1018
+ ``.*[.](?!bat$|exe$)[^.] *$ ``
1018
1019
1019
1020
1020
1021
Modifying Strings
You can’t perform that action at this time.
0 commit comments