Please help me to make a Regular Expression with following rule –
- Max number can be 9999.99
- Should be non-negative
- Can not be 0, but 0.01 and so on is valid
- So, I need a non negative number between 0.01-9999.99
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Erm, this isn’t really a job for Regexp, but it works with it anyway:
A More strict evaluation would be:
With not accepting leading zero’s, but allowing for just one decimal: “0.1”.
Bear in mind, decimals are optional.
I suggest, however, to use mathematical operations: Convert to float and then check:
You can use
sprintf()to get the representation that you need, for instance limiting the number of decimals, etc.