File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1013,7 +1013,9 @@ extension. This regular expression matches ``foo.bar`` and
10131013Now, consider complicating the problem a bit; what if you want to match
10141014filenames where the extension is not ``bat ``? Some incorrect attempts:
10151015
1016- ``.*[.][^b].*$ `` The first attempt above tries to exclude ``bat `` by requiring
1016+ ``.*[.][^b].*$ ``
1017+
1018+ The first attempt above tries to exclude ``bat `` by requiring
10171019that the first character of the extension is not a ``b ``. This is wrong,
10181020because the pattern also doesn't match ``foo.bar ``.
10191021
@@ -1040,7 +1042,9 @@ confusing.
10401042
10411043A negative lookahead cuts through all this confusion:
10421044
1043- ``.*[.](?!bat$)[^.]*$ `` The negative lookahead means: if the expression ``bat ``
1045+ ``.*[.](?!bat$)[^.]*$ ``
1046+
1047+ The negative lookahead means: if the expression ``bat ``
10441048doesn't match at this point, try the rest of the pattern; if ``bat$ `` does
10451049match, the whole pattern will fail. The trailing ``$ `` is required to ensure
10461050that something like ``sample.batch ``, where the extension only starts with
You can’t perform that action at this time.
0 commit comments