 <p>Try this updated regex:</p> <pre><code>(?&lt;=href\=\")[^&lt;]*?(?=\"&gt;\[link\]) </code></pre> <p>See <a href="https://www.regex101.com/r/pZ1gK9/1" rel="nofollow">demo</a>. The problem is that the dot matches too many characters and in order to get the right 'href' you need to just restrict the regex to <code>[^&lt;]*?</code>.</p>