Due to some bad actions performed a long time ago, some junk data exists on the website content page. this morning, I added a method to remove the text of the string hyperlink. next I will use the regular expression to process it. The function of the following instance is to filter all html tags and replace the h1-h5 before... due to some bad actions performed a long time ago, some junk data exists on the website content page. this morning, I added a method to remove the text of the string hyperlink. next I will use the regular expression to process it.
The functionality of the following instance is to filter all html tags and replace all text before the h1-h5
%% '"; $ Query = mysql_query ($ SQL) or die (mysql_error (); if (mysql_num_rows ($ query) {while ($ rs = mysql_fetch_array ($ query )) {// print_r ($ rs); $ t = stripslashes ($ rs ['field']); $ str = nl2br (strip_tags (addslashes (removelink ($ t); $ SQL = "update table name set field = '$ str 'Where id = ". $ rs ['id']; if (mysql_query ($ SQL) {echo $ rs ['id']. 'success
';} Else {echo mysql_error () ;}} else {echo' has been updated and has not recorded '. $ SQL .'
';}} Function removelink ($ t) {// $ str = preg_replace ("/] * href = [^>] *> |
] *>/I "," ", $ t); $ str = preg_replace ("/(? Is )(? <= ).*? (? =)/I "," ", $ t); $ str = preg_replace ("/(? Is )(? <= ).*? (? =)/I "," ", $ str); $ str = preg_replace ("/(? Is )(? <= ).*? (? =)/I "," ", $ str); $ str = preg_replace ("/(? Is )(? <= ).*? (? =)/I "," ", $ str); $ str = preg_replace ("/(? Is )(? <= ).*? (? =)/I "," ", $ str); return re_h ($ str);} function re_h ($ str) {$ str = str_replace ('','', $ str); $ str = str_replace ('','', $ str); $ str = str_replace ('','', $ str ); $ str = str_replace ('','', $ str); $ str = str_replace ('','', $ str); $ str = str_replace ('', '', $ str); $ str = str_replace ('', '', $ str); $ str = str_replace ('', '', $ str ); $ str = str_replace ('','', $ str); $ str = str_replace ('','', $ str); re Turn $ str ;}?>
The following regular expression is used.
preg_replace("/(?is)(?<=).*?(?=)/i","",$t);
This is the core code.
For example, if you want to remove the hyperlink content from the text, you need to use a regular expression. For example, you can use $ str = preg_replace ("/] * href = [^>] *> | ] *>/I "," ", $ strhtml); to meet the requirements, see the following for more solutions.
1. delete the hyperlink in the content
ereg_replace(']*)>([^<]*)','2',$content);ereg_replace("]*>|","",$content);
2. remove hyperlinks containing specific words
$ Find = "this string is my find ";
$ String = 'replaced'; // The content of the hyperlink.
Echo ereg_replace ('] *)> ([^ <] *'. $ find. '[^>] *)', '2', $ content );
Site original, reproduced must indicate the source of http://www.phprm.com otherwise the consequences at your own risk
Permanent address:
Reprint at will ~ Please bring the tutorial URL ^