Most of the time we are clearing HTML tags but always want to keep some of the tags
Implement in ASP language
Str= "<a href=" "a.htm" ">a.htm</a><div>afefe</div>feaa<b>bbb</b><a href= Http://www.baidu.com id= "" GGG ">ggg</a><abbr> test </abbr>" Set re=new RegExp re. IgnoreCase =true Re. Global=true Re. Pattern= "(< (?! /? (a|p|b) (\s|>)) [^>]*>) " str=re.replace (str," ")
The regular can also be implemented in other languages.
The following are implemented in the PHP language:
$str = ' <a href= ' a.htm ' >a.htm</a><div>afefe</div>feaa<b>bbb</b><a href=http ://www.baidu.com id= "GGG" >ggg</a><abbr> test </abbr> ' echo preg_replace ('/(< (?! \/? (a|p|b) (\s|\>)) [^>]*>)/', ', $str);?>
Of course, PHP has a simpler way of implementing it:
$str = ' <a href= ' a.htm ' >a.htm</a><div>afefe</div>feaa<b>bbb</b><a href=http ://www.baidu.com id= "GGG" >ggg</a><abbr> test </abbr> "Echo strip_tags ($str, ' <b><a> <p> ');
Clear HTML tags but keep some of the labels