title: Regex to Select a Sub-Set of a Regex Select
body: <p>I haven't had any luck searching on this and I believe that's because I don't know the key terms to use to explain what I'm looking for. I have the following regex that I'm using to distinguish internal links on a set of HTML pages from external links:</p>
  
  <pre><code>(?&lt;=a href=")[^http](.*?)(\.html")
  </code></pre>
  
  <p>So it won't select "<a href="http://www.example.com/foo/bar.html" rel="nofollow">http://www.example.com/foo/bar.html</a>" from:</p>
  
  <pre><code>&lt;a href="http://www.example.com/foo/bar.html"&gt;bar&lt;/a&gt;
  </code></pre>
  
  <p>but will select "/foo/bar.html" from:</p>
  
  <pre><code>&lt;a href="/foo/bar.html"&gt;bar&lt;/a&gt;
  </code></pre>
  
  <p>This much is working great. Now I want to do a subselect on the selected string "/foo/bar.html" to isolate just the ".html" part. Is this possible? Possibly with a substring or another lookbehind/forward? I've setup an example here:</p>
  
  <p><a href="https://www.regex101.com/r/gZ6bP5/2" rel="nofollow">https://www.regex101.com/r/gZ6bP5/2</a></p>
  
  <p>This is for a global find/replace in Sublime Text Editor. So I believe I am restricted to just the regex for this. I understand that a variable find/replace is possible, but I have not been able to find an example of that in action.</p>
  
  <p><strong>EDIT:</strong> Just to clarify, the regex I have to distinguish between external/internal links works great (although imperfectly as commenters have noted). The question is about how to select just the ".html" portion of the match. </p>
  
  <p>Thanks in advance!</p>