页面导航: 首页网络编程正则表达式 → 正文内容

[asp]中的正则表达式运用代码

发布:dxy 发布日期:2007-8-1 19:45:16 字体:[增加 减小] 类型:转载
今天在改一套b2b的电子商务系统时,发现ASP正则,虽然用ASP很久了,但从来没用过正则表达式,这套系统中有个正则的函数很不错,自己看吧。

<%  
Function RegExpTest(patrn, strng) 
    Dim regEx, Match, Matches   ' 建立变量。 
    Set regEx = New RegExp   ' 建立正则表达式。 
     regEx.Pattern = patrn   ' 设置模式。 
    regEx.IgnoreCase = False   ' 设置是否区分字符大小写。 
    regEx.Global = True   ' 设置全局可用性。 
    Set Matches = regEx.Execute(strng)   ' 执行搜索。 
    For Each Match In Matches   ' 遍历匹配集合。 
    On Error Resume Next 
    RetStr = RetStr & Match.Value&"|" 
    Next 
    RegExpTest = RetStr 
End Function 
 str = "我来自#5565#哈哈" 
 strInfo = RegExpTest("#\w+(\((\b[,0-9]+\b)?\))?#", str) 
 Response.Write(strInfo) 
%> 

再看一例:

Function noHtml(str) 
     Dim re 
     Set re=New RegExp 
     re.IgnoreCase =True 
     re.Global=True 
     re.Pattern="(\<.*?\>)" 
     str=re.Replace(str,"") 
     re.Pattern="(\<\/.*?\>)" 
     str=re.Replace(str,"") 
     noHtml=str 
End Function
百度中搜索更多的关于[asp]中的正则表达式运用代码内容,或者用Google搜索相关更多
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行