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

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -