Regular Expression for Decimal or Blank

Posted by Phil P on Stack Overflow See other posts from Stack Overflow or by Phil P
Published on 2010-03-24T14:55:16Z Indexed on 2010/03/24 15:03 UTC
Read the original article Hit count: 362

Filed under:

Sorry for the potentially dumb question but I am trying to pull together a regular expression that will allow:

A number with 1 or 2 numbers before a decimal point, and 0-6 numbers after the decimal point. However I also need to allow the field to be blank if so required.

Valid Examples 0.952321 1.20394 12.12 25 Blank

Invalid Examples 123.45678 1.1234567

Please can anyone help?

© Stack Overflow or respective owner

Related posts about regex