日期:2014-05-16  浏览次数:20313 次

100分求个剔除html标记的正则
像这样的:
<font   color= '#000000 '   style= 'font-size:   12pt '> <b> sad </b> </font>
<font   color= '#000000 '   style= 'font-size:   12pt '> <b> <i> sad </i> </b> </font>
取sad

谢谢!

------解决方案--------------------
<script language=javascript>
var str= " <font color= '#000000 ' style= 'font-size: 12pt '> <b> sad </b> </font> "
var str2= " <font color= '#000000 ' style= 'font-size: 12pt '> <b> <i> sad2 </i> </b> </font> "
re=/ <font[^> ]*> ( <.+?> )*(.+?)( <.+?> )* <\/font> /ig
re.test(str2)
alert(RegExp.$2)
</script>
------解决方案--------------------
<script language=javascript>
var str= " <font color= '#000000 ' style= 'font-size: 12pt '> <b> sad </b> </font> "
var str2= " <font color= '#000000 ' style= 'font-size: 12pt '> <b> <i> sad2 </i> </b> </font> "
re=/( <.+?> )*([^ <]+)( <.+?> )*/ig
re.test(str)
alert(RegExp.$2)
</script>

------解决方案--------------------
http://community.csdn.net/Expert/topic/5374/5374314.xml?temp=.8886835
------解决方案--------------------
里面有我写的一个JS的方法和一个VBS的方法。。
可以修改下。。把无结束标记直接写到判断里。
------解决方案--------------------
string newtext=System.Text.RegularExpressions.Regex.Replace(oldText, " <[^> ]+> ", " ");
------解决方案--------------------
http://bbs.51js.com/thread-65208-1-1.html

<script>
str = '对不起,您的注册资料 <font color= "red "> <b> 未通过审核。 </b> </font> 原因为: <font color= "red "> 资料不完整! </font> '
str=str.replace(/ <\/?[^> ]*> /g, " ")
alert(str)
</script>
------解决方案--------------------
/ <[^> ]*> /g 强制销毁全部标签
/ <(font|b|i)[^> ]*/ig销毁全部枚举的标签
------解决方案--------------------
<[\/]?[^> ]+>
------解决方案--------------------
直接用innerText