php - Removing special character from a string -
i want remove special character @ next string
$string="test <a href='/group/profile/1'>@test user</a> test <a href='/group/profile/2'>@user test</a>"; expected output:
<a href='/group/profile/1'>test user</a> test <a href='/group/profile/2'>user test</a>" here need check each anchor tags in string , need find anchor tags word profile in href , need remove @ link text.if there @ outside anchor tag in string should not removed, @ in anchor tag need removed.
use regular expression:
$string = preg_replace('/(<a href.*profile.*>)@/u', '$1', $string); mind ungreedy (u) modifier.
php
No comments:
Post a Comment