当前位置:主页 > 查看内容

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

发布时间:2021-07-15 00:00| 位朋友查看

简介:比如1223445677777778aabbcccccccccc经过过滤之后就是12345678abc 复制代码 代码如下: % '过滤重复 Functionnorepeat(Str) DimRegEx IfIsNull(Str)OrStr=""ThenExitFunction SetRegEx=NewRegExp RegEx.Global=True RegEx.IgnoreCase=True RegEx.MultiLine=Tr……
比如 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)    
%> 


原文链接:https://m.jb51.net/article/14997.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:用Javascript正则实现url链接的解析类 下一篇:没有了

推荐图文


随机推荐