As the title states: Can any one help me figure out how to write a JavaScript regex expression that matches a string that end in “.js” but fails when given a string that ends in “-min.js”.
Examples:
hello.js -> match
hellomin.js -> match
hello-min.js -> no match
hello-min-hello.js -> match
Thanks!
Use negative lookahead:
(?!-min)[\w-]{4}\.js$Update
This will also work for less than 4 characters before the
.js:(?:(?!-min)[\w-]{4}|^[\w-]{1,3})\.js$