Regular Expressions in MS Access VBA?

后端 未结 2 1193
情书的邮戳
情书的邮戳 2020-12-16 15:59

I definitely like MS Access as an RAD-Tool for small-scope data-driven applications. But one thing I really miss as a .Net-Developer is Regular Expressions. They really come

相关标签:
2条回答
  • 2020-12-16 16:55

    You can use CreateObject("vbscript.regexp") or just reference the scripting library.

    0 讨论(0)
  • 2020-12-16 16:56

    You can use the VBScript Regex Object by adding a reference to the Microsoft VBScript Regular Expressions library.

    Example usage:

    Dim szLine As String  
    Dim regex As New RegExp  
    Dim colregmatch As MatchCollection  
    
    With regex  
       .MultiLine = False  
       .Global = True  
       .IgnoreCase = False  
    End With  
    
    szLine = "Analyzed range (from-to)  10  100"  
    
    regex.Pattern = "^Analyzed range"  
    If regex.Test(szLine) Then  
       regex.Pattern = ".*?([0-9]+).*?([0-9]+)"  
       Set colregmatch = regex.Execute(szLine)  
    
       'From  
        Debug.Print colregmatch.Item(0).submatches.Item(0)  
        'To  
        Debug.Print colregmatch.Item(0).submatches.Item(1)  
    End If  
    

    Source: http://mark.biek.org/blog/2009/01/regular-expressions-in-vba/

    0 讨论(0)
提交回复
热议问题