Regex for matching string not ending or containing file extensions
<p>In a Java application, I need to write a <code>String</code> containing a regex for URIs, so that the URI does not contains character sequences like <code>.js?</code>, <code>.css?</code> and <code>.jpg?</code>, but are also not ending with <code>.js</code>, <code>.css</code> and <code>.jpg</code></p>

<p>I made the following:</p>

<pre><code>(?:.js|.css|.jpg)$|(?:.js[?]|.html[?]|.jpg[?])
</code></pre>

<p>Which basically matches all the URIs ending with the given file extensions or containing the file extension plus the question mark.</p>

<p>How can I do the negation of the and of the previous conditions?</p>

<p>So, for instance I expect that the following URI will match</p>

<pre><code>"/a/fancy/uri/.js/which/is/valid"
</code></pre>

<p>but both the following will not</p>

<pre><code>"/a/fancy/uri/which/is/invalid.js"
"/a/fancy/uri/which/is/invalid.js?ver=1"
</code></pre>