1

Hi I am creating a regular expression that should allow 1 or more digits to be entered, and only 2 digits after an optional period(.) It should not allow letters or any other keys.

So for example it should allow: 4 44444 44.44

and prevent a % 44.4444 .44

I have [-+]?[0-9]*\.?[0-9][0-9] so far but it does not allow me to enter a single digit only. Everything else is fine. has anyone any suggestions im a newbie and hoping its something simple?

Thanks

  • possible duplicate of [Simple regular expression for a decimal with a precision of 2](http://stackoverflow.com/questions/308122/simple-regular-expression-for-a-decimal-with-a-precision-of-2) – Blue Ice Mar 18 '14 at 21:28

1 Answers1

0
[-+]?[0-9]*(\.[0-9]{2})?

Regular expression visualization

Debuggex Demo

tommoyang
  • 329
  • 1
  • 6