I want to remove the special character @
from the following string
$string="Test <a href='/group/profile/1'>@Test User</a> another test <a href='/group/profile/2'>@User Test</a>";
Expected output:
<a href='/group/profile/1'>Test User</a> another test <a href='/group/profile/2'>User Test</a>"
Here i need to check each anchor tags in the string and need to find only the anchor tags with the word profile in href and need to remove the @
from the link text.If there is any @
outside the anchor tag in the string it should not be removed, only the @
in the anchor tag need to be removed.
Use a regular expression:
$string = preg_replace('/(<a href.*profile.*>)@/U', '$1', $string);
Mind the ungreedy (U) modifier.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments