Regex for number with decimals and thousand separator

/^\d{1,3}(,\d{3})*(\.\d+)?$/

About the minimum and maximum values… Well, I wouldn’t do it with a regex, but you can add lookaheads at the beginning:

/^(?!0+\.00)(?=.{1,9}(\.|$))\d{1,3}(,\d{3})*(\.\d+)?$/

Note: this allows 0,999.00, so you may want to change it to:

/^(?!0+\.00)(?=.{1,9}(\.|$))(?!0(?!\.))\d{1,3}(,\d{3})*(\.\d+)?$/

which would not allow a leading 0.

Edit:
Tests: http://jsfiddle.net/pKsYq/2/

Leave a Comment