asp正則過濾重復字符串的代碼
更新時間:2008年06月28日 01:09:21 作者:
asp下過濾重復字符串的代碼,有時候我們需要過濾一些重復的字符串,下面的代碼即可解決這個問題
比如 1223445677777778aabbcccccccccc 經(jīng)過過濾之后就是12345678abc
<%
'過濾重復
Function norepeat(Str)
Dim RegEx
If IsNull(Str) Or Str="" Then Exit Function
Set RegEx=New RegExp
RegEx.Global = True
RegEx.IgnoreCase=True
RegEx.MultiLine = True
RegEx.pattern="(.)\1+"
str=regEx.replace(str,"$1")
Set RegEx=Nothing
Norepeat=str
End Function
'示例
s="1223445677777778aabbcccccccccc"
response.write Norepeat(s)
%>
復制代碼 代碼如下:
<%
'過濾重復
Function norepeat(Str)
Dim RegEx
If IsNull(Str) Or Str="" Then Exit Function
Set RegEx=New RegExp
RegEx.Global = True
RegEx.IgnoreCase=True
RegEx.MultiLine = True
RegEx.pattern="(.)\1+"
str=regEx.replace(str,"$1")
Set RegEx=Nothing
Norepeat=str
End Function
'示例
s="1223445677777778aabbcccccccccc"
response.write Norepeat(s)
%>
相關文章
eregi_replace與preg_replace 函數(shù)代碼的用法比較
eregi_replace與preg_replace 函數(shù)代碼的用法比較...2007-03-03

