Hi Folks!

I was following a thread awhile back in which Dana DeLouis posted this UDF
that returns the last string of numbers contained inside a string:

11xxx1xx10 = 10
aa22xxxxxx = 22
2xxxxxxxxx = 2
xx12xxx5xx = 5

This works beautifully when the "numbers" are integers.

Can this code be modified to return the number string if it also contains
decimals?

As is, it won't:

11xxx10.1 = 1
xxx5.25xx = 25

Where the above should return:

10.1
5.25

Here's the code:

Option Explicit
Public RE As RegExp

Function LastGroupOfNumbers(s)
'// Microsoft VBScript Regular Expressions 5.5

Dim Matches As MatchCollection
Const k As String = "(\d+)\D*$"

If RE Is Nothing Then Set RE = New RegExp
With RE
.IgnoreCase = True
.Global = True
.Pattern = k

If .Test(s) Then
Set Matches = .Execute(s)
LastGroupOfNumbers = Matches(0).SubMatches(0)
End If
End With
End Function

Thanks

Biff