Reputation: 58063
With reference to my previous question currency regex
I want to add an condition, i want to allow decimal only if it starts with 0
example
0.25 should be allowed 1.25 not allowed
current regex is as following
/^(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?$/
which matches comma trailing etc.
Upvotes: 0
Views: 290
Reputation: 4089
This will match all the currency matches from before without decimals or decimals with 0.x*
/^((?:\d{1,3}(?:,\d{3})+|\d+)|(?:0\.\d+))$/
If you only want to match 0.xx instead of an arbitrary number of decimal places use
/^((?:\d{1,3}(?:,\d{3})+|\d+)|(?:0\.\d{2}))$/
This one changes \d+
, one or more digits, to \d{2}
, exactly 2 digits.
Upvotes: 1