asp 正則 過濾重復字符串的代碼
更新時間:2009年10月12日 15:13:42 作者:
asp下過濾重復字符串的代碼,有時候我們需要過濾一些重復的字符串,下面的代碼即可解決這個問題。
比如 1223445677777778aabbcccccccccc 經過過濾之后就是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)
%>
相關文章
JavaScript正則表達式驗證身份證號碼是否合法(兩種方法)
正則表達式(regular expression)是一個描述字符模式的對象。下面通過本篇文章給大家介紹js正則表達式驗證身份證號碼是否合法,需要的朋友可以參考下本篇文章2015-09-09詳解基于Linux下正則表達式(基本正則和擴展正則命令使用實例)
正則表達式應用廣泛,在絕大多數的編程語言都可以完美應用,在Linux中,也有著極大的用處。 有興趣的可以了解一下。2017-01-01