RegEx library

Petr Danes

Registered User.
Local time
Today, 14:53
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
 
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
This is a perfect example of a change which DID need doing and wasn't change for changes sake. Whilst I can see a logistic challenge with users on various Access version, it is simplicity itself on an individual basis: basically a global replace.
 
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
I guess you called it. Got all the current updates installed and the DB works fine. I recall now that all the problems I was having with some machines working and some not all came around the time this upgrade from MS was happening. I thought it had all been solved, then this machine suddenly threw a fit again, and I thought I was back in the middle of it. But it has not been turned on since last August, it turns out, and resurfacing of the problem was just that the OS was woefully out of date.

Live and learn, I guess. Or in my case, live and learn, then forget, then get whacked again, then learn again, rinse, repeat...

Anyway, thanks.
 
Just for clarification, I think you meant Office was out of date. The OS version shouldn’t matter.

AFAIAA, all the RegEx functionality from the VBScript library was ported to the VBA library though I haven’t needed to use it much myself in the past year or so. I haven’t heard of any missing features.
 
Just for clarification, I think you meant Office was out of date. The OS version shouldn’t matter.

AFAIAA, all the RegEx functionality from the VBScript library was ported to the VBA library though I haven’t needed to use it much myself in the past year or so. I haven’t heard of any missing features.
Yeah, could be. I just went to Windows Update and clicked through the required stuff there, but didn't pay any attention to what it was actually doing. Cycled until it stopped whining, tried the DB and all is now fine.
 

Users who are viewing this thread

Back
Top Bottom