Regex using Interval Matching (Exact or Range)

I'm trying to use the regex feature of Ms Access 2007 VBA but I'm doing something wrong.

If I have a regex of:

\$\d{3,5}\.\d{2}

The following gives me a True: $123.45 And these give me False: $12.23 or $123456.45 So all is good with this.

However, if I now test this, it gives me True !?

$123.456

Isn't the second section of my regex, ie \d{2} stating that I can only have two digits after the decimal/period? This problem also occurs even if I put a boundary, ie \d{2,2}


Sorry; figured it out. I used the boundaries functionality.

Therefore the following now works:

\$\d{3,5}\.\b\d{2}\b

If there are any other thoughts or suggestions I'd still be more than grateful

Answers


' you confirmed you don't want this ...
? RegExpTest("$123.456", "\$\d{3,5}\.\d{2}")
True
' you can add "$" to the regex pattern ...
? RegExpTest("$123.456", "\$\d{3,5}\.\d{2}$")
False

Function RegExpTest(ByVal pSource As String, _
        ByVal pPattern As String) As Boolean
    Dim re As Object ' New RegExp
    Set re = CreateObject("VBScript.RegExp")
    With re
        .Pattern = pPattern
        .IgnoreCase = True
        .Global = False
        .MultiLine = False
    End With
    RegExpTest = re.Test(pSource)
    Set re = Nothing
End Function

Need Your Help

can't get sIFR to work

sifr

I have tried using sIFR on a test page http://www.irwinassociates.eu/test.php without success. I have checked and re-checked but can't find what's wrong. I figure it's something simple. Can anyone ...