Here's an example console application:
Module Module1
Sub Main()
Dim results As List(Of NumericValue) = GetNumericValues("What is 2 * 2?")
For Each i As NumericValue In results
Console.WriteLine("{0}: {1}", i.Position, i.Value)
Next
Console.ReadKey()
End Sub
Public Class NumericValue
Public Sub New(value As Decimal, position As Integer)
Me.Value = value
Me.Position = position
End Sub
Public Property Value As Decimal
Public Property Position As Integer
End Class
Public Function GetNumericValues(data As String) As List(Of NumericValue)
Dim values As New List(Of NumericValue)()
Dim wordDelimiters() As Char = New Char() {" "c, "*"c, "?"c}
Dim position As Integer = 0
For Each word As String In data.Split(wordDelimiters, StringSplitOptions.None)
Dim value As Decimal
If Decimal.TryParse(word, value) Then
values.Add(New NumericValue(value, position))
End If
position += word.Length + 1
Next
Return values
End Function
End Module
As you can see, it passes the string `"What is 2 * 2?" and it outputs the positions and values of each numeric value:
8: 2
12: 2