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.Reg ularExpressions .Regex(pattern)
Debug.WriteLine (theRegex.IsMat ch("earns $21..25 from"), "$21..25")
Debug.WriteLine (theRegex.IsMat ch("earns $21.25 from"), "$21.25")
Debug.WriteLine (theRegex.IsMat ch("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.Reg ularExpressions .Match =
theRegex.Match( "earns $21.25 from")
Debug.WriteLine (theMatch.Group s("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*******@wher ever.com> wrote in message
news:Ot******** ********@tk2msf tngp13.phx.gbl. ..
Is there anything better than: 'earns \$\d+\.*\d* from' ?
"George Yachán" <2m*******@wher ever.com> wrote in message
news:Oq******** ********@TK2MSF TNGP11.phx.gbl. .. What would the regular expression be to return both of the following?
Thank you.
'earns $21.25 from"
'earns $21 from"