Nelviticus
Programmer
I have a string and I need to test whether its contents are convertable to currency - i.e. "36.45" or "123456" would be valid but "36.45.92" or "wubble" would not.
I could [tt]try[/tt] to use [tt]Convert.ToDecimal(sMyString)[/tt] and [tt]catch[/tt] any errors but that seems a bit messy.
I tried to use regular expression matching like this:
but I don't really know the regular expression syntax well enough and the above gives false positives and false negatives.
Any idea how to do this?
Nelviticus
I could [tt]try[/tt] to use [tt]Convert.ToDecimal(sMyString)[/tt] and [tt]catch[/tt] any errors but that seems a bit messy.
I tried to use regular expression matching like this:
Code:
[COLOR=blue]if[/color] (!Regex.IsMatch(sMyString, @"^\\d*\\.?\\d*"))
but I don't really know the regular expression syntax well enough and the above gives false positives and false negatives.
Any idea how to do this?
Nelviticus