regex - RegExp to return decimal number with optional 2-4 decimal dights -
i have develop regexp matches number following:
*.0000 -> *.00
*.1234 -> *.1234
*.1200 -> *.12
*.1230 -> *.123
i think looking this:
\.\d{2}(0[1-9]|[1-9]{1,2})?
starts dot , 2 digits \.\d{2}
then optional 0 followed digit 0[1-9]
or 1 or 2 non-zero digits [1-9]{1,2}
matches examples correctly.
if want digits in front (your question states decimal number) add \d*
in front of \.
... if need more specific you'll have clarify question.
Comments
Post a Comment