浏览模式: 普通 | 列表
5月, 2010 | 1

asp正则表达式RegExp的Replace方法

[ 2010-05-24 22:20:21 | 作者: admin ]
Function StrReplace(s As String, p As String, r As String) As String
        
         Dim re As RegExp
         Set re = New RegExp
           re.IgnoreCase = True
           re.Global = True
           re.Pattern = p
           StrReplace = re.Replace(s, r)
        
End Function

Private Sub Command2_Click()

         Dim s As String '字符串
         Dim p As String '正则表达式
         Dim r As String '要替换的字符串

  '以下代码是替换邮箱地址
...

阅读全文…

asp正则表达式中 Match的SubMatches属性

[ 2010-05-24 22:12:43 | 作者: admin ]
Private Sub Command3_Click()

        Dim re As RegExp
        Dim mh As Match
        Dim mhs As MatchCollection
        Dim inpStr As String
       
          inpStr = "我的E-mail: ***@gmail.com ,欢迎来函!"
        Set re = New RegExp
          re.Pattern = "(w+)@(w+).(w+)" ‘需要用小括号来分组,否则SubMatches无法使用
        Set mhs = re.Execute(inpStr)
        Set mh = mhs(0) '只有一个匹配
...

阅读全文…
1