Reputation: 9403
I want to validate string decimal number with some mathematic operator using Regex
like
<=-5.6
<10
>=10
10.5
<=-20.4
2.
-.2
>-5.
Invalid string like
<>5
=>5.6
5.6>=
Upvotes: 0
Views: 89
Reputation: 56586
This regex passes your test cases:
var regex = new Regex(@"^([<>]=?)?-?(\d+\.?|\d*\.?\d+)$");
bool isMatch = regex.IsMatch(testString);
Upvotes: 3