I have a super screwed up data sets, with no real pattern, all I need from it is to find digit sequences from 3 to 7 digits, this is what I have been trying but matches.Count always gives 0
Function catchNumbers(inSt As String)
Dim regex As Object, str As String
Set regex = CreateObject("VBScript.RegExp")
With regex
.Pattern = "\d{3-7}"
.Global = True '
.IgnoreCase = True
End With
inSt = Replace(inSt, ".", "")
Set matches = regex.Execute(inSt)
Debug.Print (matches.Count())
If matches.Count() > 0 Then
For Each StrFound In matches
Debug.Print (TypeName(StrFound) & " : " & StrFound)
str = str & " " & StrFound
Next StrFound
Else
str = ""
End If
If Left(str, 1) = " " Then
str = Right(str, Len(str) - 1)
End If
Debug.Print (str)
catchNumbers = str
End Function
Example of datasets :
25.802; 24.052/Guaiba 25.802; 24.052/Guaiba 25.859, L. 3-Ac, Fls.5; 25.862, L. 3-Ac, Fls. 6; 25.865, L. 3-Ac, Fls. 7; 25.856, L. 3-Ac, Fls. 4 25.859, L. 3-Ac, Fls.5; 25.862, L. 3-Ac, Fls. 6; 25.865, L. 3-Ac, Fls. 7; 25.856, L. 3-Ac, Fls. 4
\d{3,7}