Hi all,

Been at this for a while now and finally gave in to seek help.

Basically, I'm trying to setup a regular expression for a decimal. Where there's 1 to 7 integers in front of the decimal point, and 1 to 2 after the decimal point.

This is what I got so far:


It ALMOST works.

This number should be the absolute maximum that can match: 1234567.12

These numbers are matching, when they shouldn't be


As you can see, it's matching passed the "maximum".

Any ideas?

"/^(\d{1,7})\.(\d{1,2})$/" If you're testing a string you want to set the anchors "^" (beginning of string) and "$" (end of string) so you know that there is nothing else in between. "/(\d{1,7})\.(\d{1,2})/" will match 12345678.12 because it is matching, take a look at this.

without ^$
that's 7 numbers a decimal and 2 numbers, so a match
with anchors
no match

That did the trick!

Thanks for the answer as well as the explanation. Definitely good to know! :)