title: regex pattern for match with extension of URL
body: <p>I have these sample URLs:</p>
  
  <pre><code>1) example.com/foo.js
  2) example.com/foo.js?
  3) example.com/foo.js?bar
  
  4) example.com/foo.jsbar
  5) example.com/foo.js/bar
  </code></pre>
  
  <p>I want regex js for match with 1, 2, 3 and don't match with 4, 5. with extension.</p>
  
  <p>I use this pattern in <a href="http://livehttpheaders.mozdev.org/" rel="nofollow noreferrer">LiveHTTP headers add-on firefox</a>.</p>
  
  <p>Firstly I write this:</p>
  
  <pre><code>.js$
  </code></pre>
  
  <p>This just point to the 1.</p>
  
  <p>And this:</p>
  
  <pre><code>.js\?
  </code></pre>
  
  <p>Point to the 2, 3.</p>
  
  <p>And this:</p>
  
  <pre><code>.js\??$
  </code></pre>
  
  <p>Point to 1, 2.</p>
  
  <p>So finally I write this:</p>
  
  <pre><code>.js$|.js\?
  </code></pre>
  
  <p>This works well.</p>
  
  <p>Test online: <a href="https://regex101.com/r/BU5IqH/2" rel="nofollow noreferrer">https://regex101.com/r/BU5IqH/2</a></p>
  
  <p>Now my question is how can I have a regex with use once <code>.js</code> string in the pattern?</p>