php超連結常用的正規表示式

2021-06-06 03:23:43 字數 779 閱讀 6671

1、刪除內容中的超連結

ereg_replace(']*)>([^<]*)','\\2',$content);

ereg_replace("]*>|<\/a>","",$content);

2、消除包含特定詞的超連結

$find="this string is my find";

$string='替換掉了';//將超連結替換成的內容

echo ereg_replace(']*)>([^<]*'.$find.'[^>]*)','\\2',$content);

3、獲取超連結文字內容

//方法一

preg_match_all('/<(a|a)[s][w=":()]*>[nrn]*(check user)[nrn]*/i',$string,$matches);

//方法二

preg_match_all('/check user/i',$string,$matches);

print_r($matches);

//方法三

preg_match_all('/]*>[^<]*/i',$string,$matches);

print_r($matches);

//方法四

preg_match_all('/check user/is',$str,$arr);

print_r($arr);

//方法五

preg_match_all('/check user/is',$str,$arr);

print_r($arr);

超連結提取的正規表示式

匯入 using system.text.regularexpressions 測試成功 string str regex re new regex href s s s regexoptions.ignorecase regexoptions.singleline matchcollection ...

PHP使用正規表示式清除超連結文字

可以用 str preg replace href i strhtml 這段來實現需求,如果想要更多解決方法,可以參看以下的。1 刪除內容中的超連結 複製 如下 ereg replace 2 content ereg replace content 2 消除包含特定詞的超連結 複製 如下 find ...

PHP正規表示式提取html超連結中的href位址

有時我們需要過濾或提取html字串的外鏈結了,下面我介紹乙個利用php正則表示式提取html超連結中的href 用php的正則表示式相關函式,實現提取html超連結中的位址。如下 複製 preg is str urlname文字段1urlname文字段2urlname.文字段n preg match...