Wildcards: Find any number of numeric values

Kowalski

Registered User.
Local time
Tomorrow, 01:44
Joined
Jul 5, 2007
Messages
121
How do you search for any number of numeric characters using wildcards?
The # symbol only searches for 1, and * obviously includes letters.

Example:
I have:
D1234
D3
D5336767
D123F

My search should only retrieve the first 3 values.

WHERE FieldName LIKE 'D[0-99999999]' does not seem to work.
 
have you considered using the IsNumeric function?
 
Not really, although it should work in the examples I gave.
But when you have literal characters at the end of the first 3 samples, you will run into trouble determining the length to pass to IsNumeric.
If D123456DS1234 should also be returned, as well as D1D1, then it will become tricky.
Writing a custom function looks like another solution, but wildcards or regular expressions would have made it so much simpler.
 
I wonder what you are searching for, your examples suggest any string ending with any number of numerics, in which case you need only pass the last character to IsNumeric.

Brian
 
Regular Expressions can be used in queries by creating a function in a Standard Module.

Add a reference to:
Microsoft VBScript Regular Expressions 5.5

Code:
Public Function HasNumbers(ByVal SearchTarget As String) As Boolean
 
Dim re As New RegExp
Dim Match As Variant
 
    re.Pattern = "[0-9]."
 
    For Each Match In re.Execute(SearchTarget)
        HasNumbers = Len(Match.Value)
    Next
 
End Function

I am sure if you understand Regular Expressions well enough you could modify the function to whatever you desire.
 
Not really, although it should work in the examples I gave.
But when you have literal characters at the end of the first 3 samples, you will run into trouble determining the length to pass to IsNumeric.
Asking a question properly is the start for finding a solution :banghead:
 
Last edited:

Users who are viewing this thread

Back
Top Bottom