Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This one should suit your needs:</p> <pre class="lang-none prettyprint-override"><code>&lt;a href="[^"]*?specificword.*?"&gt;.*?&lt;/a&gt; </code></pre> <p><a href="http://regexr.com/3f223" rel="nofollow noreferrer">Demo</a></p> <hr> <p>If you want to allow other attributes on your anchor tar, and be more premissive about inner spaces, you could try:</p> <pre class="lang-none prettyprint-override"><code>&lt;a( [^&gt;]*?)? href="[^"]*?specificword.*?"( .*?)?&gt;.*?&lt;/a&gt; </code></pre> <p><a href="http://regexr.com/3f226" rel="nofollow noreferrer">Demo</a></p> <hr> <p>You could also of course use non-capturing groups <code>(?:...)</code>:</p> <pre class="lang-none prettyprint-override"><code>&lt;a(?: [^&gt;]*?)? href="[^"]*?specificword.*?"(?: .*?)?&gt;.*?&lt;/a&gt; </code></pre> <p><a href="http://regexr.com/3f229" rel="nofollow noreferrer">Demo</a></p> <hr> <p>And finally, if you want to allow simple quotes for your <code>href</code> attribute:</p> <pre class="lang-none prettyprint-override"><code>&lt;a(?: [^&gt;]*?)? href=(["'])[^\1]*?specificword.*?\1(?: .*?)?&gt;.*?&lt;/a&gt; </code></pre> <p><a href="http://regexr.com/3f22c" rel="nofollow noreferrer">Demo</a></p> <hr> <p>Last but not least: if you want to capture the URL, just put parentheses around the <code>[^\1]*?specificword.*?</code> part:</p> <pre class="lang-none prettyprint-override"><code>&lt;a(?: [^&gt;]*?)? href=(["'])([^\1]*?specificword.*?)\1(?: .*?)?&gt;.*?&lt;/a&gt; </code></pre> <p><a href="http://regexr.com/3f22f" rel="nofollow noreferrer">Demo</a></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