How to validate regular expression which allow both decimals as well as integers
need to like
output 0.1, 1,1.123 etc
not enter 0
How to validate regular expression which allow both decimals as well as integers
need to like
output 0.1, 1,1.123 etc
not enter 0
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Mar 3, 2022, 12:40 AM EST
Regular Expression is : ^[1-9]\d{0,9}(\.\d{1,3})?%?$
[1-9] : for integers which allows integers from 1 to 9
d{0,9}: this will take up to 10 digits
\. : for decimal d{1,3} : for decimal up to three digits