How to replace only once and no in tag?
<p>I need to replace names in my text on site. But the name in text only needs to be replaced, and not in tag .</p>

<p>For example:</p>

<pre><code>&lt;img src="" title="Justin Bieber" /&gt; bla bla bla bla Justin Bieber bla bla bla Justin Bieber bla bla bla bla
</code></pre>

<p>To this:</p>

<pre><code>&lt;img src="" title="Justin Bieber" /&gt; bla bla bla bla &lt;a href="http://en.wikipedia.org/wiki/Justin_Bieber"&gt;Justin Bieber&lt;/a&gt; bla bla bla Justin Bieber bla bla bla bla
</code></pre>

<p><strong>I've found answer:</strong></p>

<pre><code>$text = '&lt;img src="" title="Justin Bieber" /&gt; bla bla bla bla Justin Bieber bla bla bla Justin Bieber bla bla bla bla';

$text = preg_replace('/Justin Bieber(?![^&lt;&gt;]*+&gt;)/i', '&lt;a href="http://en.wikipedia.org/wiki/Justin_Bieber"&gt;Justin Bieber&lt;/a&gt;', $text, 1);
</code></pre>

<p>Only one and no in image tag.</p>
