<%Function regExReplace(sSource,patrn, replStr) Dim regEx, str1 str1 = sSource Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True regEx.Global = True regExReplace = regEx.Replace(str1, replStr) End Function Function RegExpTest(strng,s)strng1=strngDim regEx, Match, Matches ' 建立变量。Set regEx = New RegExp ' 建立正则表达式。regEx.Pattern = s ' 设置模式。regEx.IgnoreCase = True ' 设置是否区分大小写。regEx.Global = True ' 设置全局替换。Set Matches = regEx.Execute(strng) ' 执行搜索。For Each Match in Matches ' 遍历 Matches 集合。strng1=regExReplace(strng1,Match.value,"<a href="""&Match.value&""" target=""_blank"">"&Match.Value&"</a>")NextRegExpTest = strng1end Function str="http://www.yahoo.com.cn雅虎http://www.sina.com.cn新浪http://hao123.com好123"s="((http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)"response.write RegExpTest(str,s) %>

评论