以后地位:首页 > 建站常识 > 列表

asp 正则抒发式断根表格属性

点击: 次时候:2017/11/24关头词:上海网站设想 asp正则抒发式
'用法 RHtml=SimpleHTML(html,"p,img,a,span")Function SimpleHTML(content,tags) If tags="" Then tags="p,br" SimpleHTML = RegWordStr("&l

'用法 RHtml=SimpleHTML(html,"p,img,a,span")

Function SimpleHTML(content,tags)

   If tags="" Then tags="p,br"

   SimpleHTML = RegWordStr("<(\/?)("& WordStr(tags,",","|") &")([^>]*)>",content&"","[$1$2$3]")

   SimpleHTML = RegWordStr("<[^>]*>",SimpleHTML,"")

   SimpleHTML = RegWordStr("\[(\/?)("& WordStr(tags,",","|") &")([^\]]*)\]",SimpleHTML,"<$1$2$3>")

End Function

'天生一个正则抒发式工具

Function REObject( reg, m)

   Dim re:Set re=new RegExp

   re.Pattern = reg

   If InStr(1, m, "g", 1)>0 Then re.Global = True

   If InStr(1, m, "i", 1)>0 Then re.IgnoreCase = True

   If InStr(1, m, "m", 1)>0 Then re.MultiLine = True

   Set REObject=re

End Function

Function RegWordStr( reg, str, rstr)

   RegWordStr=RegExpWordStr(reg,"ig",str,rstr)

End Function

'正则替代字符串

Function RegExpWordStr( reg, m, str, rstr)

   RegExpWordStr=REObject(reg, m).WordStr(str,rstr)

End Function

前面几个是用到的函数

会将html代码中非指定的标签全数去除,若是要去除标签内的属性,须要点窜下simplehtml这个函数,把$3去掉

Function SimpleHTML(content,tags)

   If tags="" Then tags="p,br"

   SimpleHTML = RegWordStr("<(\/?)("& WordStr(tags,",","|") &")([^>]*)>",content&"","[$1$2$3]")

   SimpleHTML = RegWordStr("<[^>]*>",SimpleHTML,"")

   SimpleHTML = RegWordStr("\[(\/?)("& WordStr(tags,",","|") &")([^\]]*)\]",SimpleHTML,"<$1$2>")

End Function


预定建站
收费供给网站优化
支付关头词