Reputation: 51
My current code is:
$epattern[17] = "/@(\\w+)/";
$ereplace[17] = "<a href=viewprofile.php?username=$1><font color=royalblue><b>@\\1</b></font></a>";
$postinforawb = preg_replace($epattern,$ereplace,$postinfo);
With the above code the text will highlight blue where the @ symbol was used up to where a space has been entered. However I now also want it to include the "+" symbol in posts. So that the following would highlight blue: "@First+Second"
What am I needing to add to the replace?
Upvotes: 1
Views: 63
Reputation: 39355
This will do in your case:
$epattern[17] = "/@([\w\+]+)/";
But i prefer this one as you are only allowing alphabet and +
:
$epattern[17] = "/@([a-zA-Z\+]+)/";
Upvotes: 2