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 @@ -1016,7 +1016,9 @@ extension. This regular expression matches ``foo.bar`` and
10161016Now, consider complicating the problem a bit; what if you want to match
10171017filenames where the extension is not ``bat ``? Some incorrect attempts:
10181018
1019- ``.*[.][^b].*$ `` The first attempt above tries to exclude ``bat `` by requiring
1019+ ``.*[.][^b].*$ ``
1020+
1021+ The first attempt above tries to exclude ``bat `` by requiring
10201022that the first character of the extension is not a ``b ``. This is wrong,
10211023because the pattern also doesn't match ``foo.bar ``.
10221024
@@ -1043,7 +1045,9 @@ confusing.
10431045
10441046A negative lookahead cuts through all this confusion:
10451047
1046- ``.*[.](?!bat$)[^.]*$ `` The negative lookahead means: if the expression ``bat ``
1048+ ``.*[.](?!bat$)[^.]*$ ``
1049+
1050+ The negative lookahead means: if the expression ``bat ``
10471051doesn't match at this point, try the rest of the pattern; if ``bat$ `` does
10481052match, the whole pattern will fail. The trailing ``$ `` is required to ensure
10491053that something like ``sample.batch ``, where the extension only starts with
You can’t perform that action at this time.
0 commit comments