RegEx library (2 Viewers)

Petr Danes

Registered User.
Local time
Today, 23:50
Joined
Aug 4, 2010
Messages
154
I have a DB that makes fairly heavy use of regular expressions. Recently, it has started crashing on SOME users' computers. It turns out that the library reference to MIcrosoft VBScript Regular Expressions 5.5 is the problem. In some machines, it MUST be set or the code crashes. In others, it must NOT be set, or the code crashes. Everyone is running Office 365, 64 bit version, Windows 10 or Windows 11. I have not been able to isolate any common characteristic to crashing when set versus crashing when not set.

I have found many references to this on the net, claiming all sorts of things, but the problem remains - neither configuration works properly on ALL my users' machines.

Has anyone run into this and found a way around it? Conditional compilation? Run-time vs compile time linking? A different library entirely? Anything?
 
Starting with version 2508, RegEx was included in the VBA Llibrary, so the VBScript library is no longer needed and indeed should no longer be used. The problem you are describing may be because you have some users on 2507 or earlier whilst others have 2508 or later.

See my article

Also read Philipp Stiefel's article on this topic
 
Starting with version 2508, RegEx was included in the VBA Llibrary, so the VBScript library is no longer needed and indeed should no longer be used. The problem you are describing may be because you have some users on 2507 or earlier whilst others have 2508 or later.

See my article

Also read Philipp Stiefel's article on this topic
Ah, yes - that could be it. The machine I just now tried it on and crashed turns out to have been out of service for quite a while. It got a new version of the DB, but maybe is running behind on OS updates. I will get it up to spec tomorrow and try again. Thanks for the tip.
 
I use VBScript.RegExp on Access version 2602 to tokenize infix math expressions used by a BOM calculator without issue. According to copilot, the native RegExp only handles case sensitive matches with no execute. Is VBScript.RegEx going away or can I can continue using it for tokenizing?

Code:
    Dim Matches As Object
    Dim result() As String
    
    ...
    
    With CreateObject("VBScript.RegExp")
        ' Pattern: identifiers start with alpha;
        '          operators and parentheses captured.
        .Global _
            = True
        .IgnoreCase _
            = True
        .Pattern _
            = "([A-Za-z0-9.]+|>=|<=|!=|<>|==|=|>|<|AND|OR|NOT|[+\-*/\\%^(),#@])"
        Set Matches _
            = .Execute(InfixExpression)
    End With
    
    ...
    
    For i = 0 To Matches.Count - 1
        Token _
            = Matches(i).Value
            
    Next
 
I think what Colin is saying is that since 2508, RegExp is directly exposed by the VBA object model...

Screenshot 2026-04-09 113630.png


...so instead of setting a reference to an external RegExp object model, or creating a late-bound instance in your VBA code, like this...
Code:
With CreateObject("VBScript.RegExp")
...you can new up a strongly-typed instance directly from VBA, like...
Code:
With New RegExp

This is actually pretty cool.
 
Yes indeed… but only since version 2508.
This is indeed useful, but more importantly it solves the problems related to VBScript being deprecated at some point in the not too distant future
 

Users who are viewing this thread

Back
Top Bottom