ASP 通过正则表达式过滤非中文字符 :
[CODE=language]ASP 通过正则表达式过滤非中文字符
<%
Function RegExpTest(strng)
i = 0
Set regEx = New RegExp
regEx.Pattern = "[^\u4e00-\u9fa5]"
regEx.IgnoreCase = True
regEx.Global = True
RegExpTest= regEx.Replace(strng,"")
End Function
response.Write(RegExpTest("aaaa.com学习更多123123"))
%>
ASP 通过正则表达式过滤html标签
<%
dim str ,str2
str = "<span class=LightText>内容,;';1986"
str = replace(str,"<","<")
str = replace(str,">",">")
response.Write(str)
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取闭合的<>
objRegExp.Pattern = "<.+?>"
'进行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍历匹配集合,并替换掉匹配的项目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
'调用
str2=RemoveHTML(str)
response.Write("
")
response.Write(str2)
%>[/CODE]