Home > Article > Backend Development > Commonly used regular expressions for php hyperlinks
1. Delete the hyperlink in the content
ereg_replace(']*)>([^<]*)','\2',$content);
ereg_replace("]*>|","",$content);
2、 Eliminate hyperlinks containing specific words
$find="this string is my find";
$string='replaced';//Replace the hyperlink Replaced content
echo ereg_replace(']*)>([^<]*'.$find.'[^>]*)',' \2',$content);
3. Get the hyperlink text content
//Method 1
preg_match_all('/<(a|a) [s]{0,1}[w=":()]*>[nrn]*(check user)[nrn]*(a|a)>/i',$string,$matches );
//Method 2
preg_match_all('/check user/i',$string,$matches);
print_r($matches);
/ /Method 3
preg_match_all('/]*>[^<]*/i',$string,$matches);
print_r($matches);
//Method 4
preg_match_all('/
print_r($arr);
//Method 5
preg_match_all('/
The above introduces the regular expressions commonly used in PHP hyperlinks, including related content. I hope it will be helpful to friends who are interested in PHP tutorials.