Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need a regular expression to validate decimal value ranges from -12.0 to +12.0

Search gave many regex but nothing worked. Anybody having correct rgex for this please help.

Thanks in advance
Posted

1 solution

Doing this kind of validation with a regexp is not the simplest way. Usually, you convert the string to its numerical value and compare to the bounds of the allowed range.

If you really want a regexp, you need to:
- accept the optional sign character, followed by
        - the digit 1 followed by the digit 2 followed by an optional . followed by any number of 0
        - or a single digit or the pair 10 or the pair 11 followed by an optional . followed by any digit(s)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900