How to match ".js" and ".css" but exclude ".min.js" and ".min.css"?

regex

Solution

You've got it quite right, except

- you need to place it before the dot

- you need to use lookbehind instead of lookahead

(?<!\.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?)

Problem

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`?

Original source