如何用ASP正则表达式编写去除重复字符串的代码?

更新于
2026-09-19 01:56:46
23阅读来源:SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计156个文字,预计阅读时间需要1分钟。

如何用ASP正则表达式编写去除重复字符串的代码?

例如:1223445677777778aabbcccccccccc 经过过滤后变为 12345678abc 复制代码代码如下:vbaFunction FilterDuplicate(Str As String) As String Dim RegEx As Object If IsNull(Str) Or Str= Then Exit Function Set RegEx=CreateObject(VBScript.RegExp) RegEx.Global=True FilterDuplicate=RegEx.Replace(Str, (\w)\1+, $1)End Function

如何用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)
%>
标签:代码比如

本文共计156个文字,预计阅读时间需要1分钟。

如何用ASP正则表达式编写去除重复字符串的代码?

例如:1223445677777778aabbcccccccccc 经过过滤后变为 12345678abc 复制代码代码如下:vbaFunction FilterDuplicate(Str As String) As String Dim RegEx As Object If IsNull(Str) Or Str= Then Exit Function Set RegEx=CreateObject(VBScript.RegExp) RegEx.Global=True FilterDuplicate=RegEx.Replace(Str, (\w)\1+, $1)End Function

如何用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)
%>
标签:代码比如