George,
Assuming you mean a number preceded by a dollar sign, I would use:
'earns \$\d+(\.\d*)? from'
As I would expect you only want a single period, and the period needs to
proceed the (optional) decimal places.
Something like:
Const pattern As String = "earns (?<amount>\$\d+(\.\d*)?) from"
'Const pattern As String = "earns (?<amount>\$\d+\.*\d*) from"
Dim theRegex As New System.Text.RegularExpressions.Regex(pattern)
Debug.WriteLine(theRegex.IsMatch("earns $21..25 from"), "$21..25")
Debug.WriteLine(theRegex.IsMatch("earns $21.25 from"), "$21.25")
Debug.WriteLine(theRegex.IsMatch("earns $21 from"), "$21")
If you use named groups as I have above, you can extra just the amount that
was matched:
Something like:
Dim theMatch As System.Text.RegularExpressions.Match =
theRegex.Match("earns $21.25 from")
Debug.WriteLine(theMatch.Groups("amount"), "amount")
The following site provides a good overview of regular expressions:
http://www.regular-expressions.info/
While this site provides the syntax specifically supported by .NET:
http://msdn.microsoft.com/library/de...geElements.asp
Hope this helps
Jay
"George Yachán" <2m*******@wherever.com> wrote in message
news:Ot****************@tk2msftngp13.phx.gbl...
Is there anything better than: 'earns \$\d+\.*\d* from' ?
"George Yachán" <2m*******@wherever.com> wrote in message
news:Oq****************@TK2MSFTNGP11.phx.gbl... What would the regular expression be to return both of the following?
Thank you.
'earns $21.25 from"
'earns $21 from"