How do I not include part of a regular expression

Posted by Axilus on Stack Overflow See other posts from Stack Overflow or by Axilus
Published on 2010-06-09T18:41:59Z Indexed on 2010/06/09 18:52 UTC
Read the original article Hit count: 215

Filed under:
|
|

I'm pretty new to using regexes and I can figure out how I would go about extracted a specific number from a string.

Suppose the string was any amount of whitespace or random text and somewhere within it is this, "Value: $1000.00."

In order to retrieve that value I am currently using this:

string value = Convert.ToString(Regex.Match(BodyContent, @"Value:[ \t]*\$?\d*(\.[0-9]{2})?", RegexOptions.Singleline));

So the variable 'value' now has, "Value: $1000.00" stored in it.

My question is, using Regex is there a way to use 'Value:' to find the number value but only store the actual number value (i.e. 1000.00) in the 'value' variable?

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex