In a Java application, I need to write a String
containing a regex for URIs, so that the URI does not contains character sequences like .js?
, .css?
and .jpg?
, but are also not ending with .js
, .css
and .jpg
I made the following:
(?:.js|.css|.jpg)$|(?:.js[?]|.html[?]|.jpg[?])
Which basically matches all the URIs ending with the given file extensions or containing the file extension plus the question mark.
How can I do the negation of the and of the previous conditions?
So, for instance I expect that the following URI will match
"/a/fancy/uri/.js/which/is/valid"
but both the following will not
"/a/fancy/uri/which/is/invalid.js"
"/a/fancy/uri/which/is/invalid.js?ver=1"