当前位置: 移动技术网 > IT编程>开发语言>正则 > asp 正则 过滤重复字符串的代码

asp 正则 过滤重复字符串的代码

2017年12月12日  | 移动技术网IT编程  | 我要评论
比如 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)
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网