欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-27 10:25:21
比如 1223445677777778aabbcccccccccc 经过过滤之后就是12345678abc 复制代码 代码如下: <% '过滤重复 function...
比如 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)
%>