' chatgpt
Function ExtractNumbers(inputString As String) As String
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
Dim matches As Object
Dim match As Object
Dim result As String
' Regular expression pattern to match numbers (including decimals)
regex.Pattern = "\b\d+(\.\d+)?\b"
regex.Global = True
regex.IgnoreCase = True
' Check if there are matches
If regex.Test(inputString) Then
' Get all matches
Set matches = regex.Execute(inputString)
' Build the result string from matches
For Each match In matches
result = result & match.Value & " "
Next match
' Remove trailing space
result = Trim(result)
End If
ExtractNumbers = result
End Function