I\'m trying to come up with a regex to validate a double value. I will admit that I am crap at regex and really should buy a book... Anyway the range is large so here goes:
Rather than a RegEx, why not use double's TryParse
method?
string[] sa = new string[] { "00.01", "1.00", "xx" };
double d;
bool isValid;
foreach (string s in sa)
{
isValid = double.TryParse(s, out d) && d >= 0.01d && d <= 99.99d;
Console.WriteLine("{0}: {1}", s, isValid.ToString());
}
^[0-9]{0,2}\.?[0-9]{0,2}$
you can try it out here: http://www.regular-expressions.info/javascriptexample.html