I tried the following without success:
\.(?!min)(js|css)$
Regex 101
I'm not very familiar with negative lookaheads, so I'm probably doing something wrong.
How can my regex be modified to match .js
and .css
but exclude .min.js
and .min.css
?
You've got it quite right, except
(?<!\.min)\.(js|css)$
With lookahead this is more complicated, altough you might manage it if you matched the complete filename:
^(.{0,3}|.*(?!\.min).{4})\.(js|css)$
(a string shorter than 4 characters or one whose last 4 characters are not .min
, isn't this horrible?)
You need to use negative lookbehind:
(?<!\.min)\.(js|css)$
RegEx Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With