<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
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)
%>
本文介绍了一段 ASP 下的代码,该代码用于过滤字符串中的重复字符。通过使用正则表达式,可以将一串包含重复字符的字符串转换为每个字符只出现一次的形式。
173

被折叠的 条评论
为什么被折叠?



