I need to extract some text from a string, then replace that text with a character removed in one instance and not in another. Hopefully this example will show you what I mean (this is what I have so far):
$commentEntry = "@Bob1990 I think you are wrong...";
$commentText = preg_replace("/(@[^\s]+)/", "<a target=\"_blank\" href=\"http://www.youtube.com/comment_search?username=${1}$1\">$1</a>", $commentEntry);
I want the result to be:
<a href="http://www.youtube.com/comment_search?username=Bob1990">@Bob1990</a> I think you are wrong...
But am getting:
<a href="http://www.youtube.com/comment_search?username=@Bob1990">@Bob1990</a> I think you are wrong...
I have been working on this one problem for at least an hour and nearly given up hope, so any help is greatly appreciated!
could try something like this