Reputation: 27733
I need to find a regex that will match up to 2 decimals, so:
are a match
are not a match
Upvotes: 0
Views: 435
Reputation: 27733
Someone wrote in the comments and I used this one: /^[0-9]+(\.[0-9]{1,2})?$/
Upvotes: 0
Reputation: 361
(^[0-9]+|^[0-9]+.)([0-9]{0,2})
The above expression will match a number to 2 decimal places. I have tested this in PHP and TextWrangler.
Upvotes: 1
Reputation: 27243
Check out www.regular-expressions.info. The examples section in particular is something you should have a look at.
Upvotes: 0