Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't see how matching one is different from the other? You're just looking for exactly what you just wrote, making the portion that is <code>doesntmatter.com</code> the part you capture. I guess matching for anything until <code>&amp;#34;</code> (not <code>&amp;quot;</code>?) can present a problem, but you do it like this in regex:</p> <blockquote> <p><code>(?:(?!&amp;#34;).)*</code></p> </blockquote> <p>It essentially means:</p> <ul> <li>Match the following group 0 or more times <ul> <li>Fail match if the following string is <code>"&amp;#34;"</code></li> <li>Match any character (except new line unless DOTALL is specified)</li> </ul></li> </ul> <p>The complete regular expression would be:</p> <pre><code>/&amp;#60;a href&amp;#61;&amp;#34;(?&gt;(?:[^&amp;]+|(?!&amp;#34;).)*)&amp;#34;&amp;#62;/s </code></pre> <p>This is more efficient than using a non-greedy expression.</p> <p>Credit to Daniel Vandersluis for reminding me of <a href="http://www.regular-expressions.info/atomic.html" rel="nofollow noreferrer">the atomic group</a>! It fits nicely here for the sake of optimization (this pattern can never match if it has to backtrack.)</p> <p>I also threw in an additional <code>[^&amp;]+</code> group to avoid repeating the negative look-ahead so many times.</p> <p>Alternatively, one could use a <a href="http://www.regular-expressions.info/possessive.html" rel="nofollow noreferrer">possessive quantifier</a>, which essentially does the same thing (your regex engine might not support it):</p> <pre><code>/&amp;#60;a href&amp;#61;&amp;#34;(?:[^&amp;]+|(?!&amp;#34;).)*+&amp;#34;&amp;#62;/s </code></pre> <p>As you can see it's <em>slightly</em> shorter.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload