Regex expression on currency in catalog item

aj2403
Tera Expert

Hi all,

Can anyone help with the regular expression for the variable in catalog item. The format should starts with '$0.00'. means it should start with $ and numerical values.00

examples are $118.09,$6.08,$3456.52,$12344.17

Thanks

1 ACCEPTED SOLUTION

var regex = /^\$(?![.0]*$)\d+\.\d{2}$/;

Hope it helps!

Please mark helpful or correct if applicable.

View solution in original post

6 REPLIES 6

Maik Skoddow
Tera Patron
Tera Patron

Hi 

/([$])([\d,.]*)/g

should do the job.

You can try it here: https://regex101.com/r/nK0jK7/1

Kind regards
Maik

If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.

Koushiki1
Tera Guru

Hi

This regex worked for me

var regex = /^\$( )*\d*(.\d{1,2})?$/;

Found it from : https://regexlib.com/Search.aspx?k=currency

Hope it helps!

Please mark helpful or correct if applicable.

Thanks for the reply, I tried its partially working. I am able to put '$134' or '$134.1' but i am looking for the format with '$134.05'. It must be 2 digits after the '.'

Thanks

var regex = /^\$(?![.0]*$)\d+\.\d{2}$/;

Hope it helps!

Please mark helpful or correct if applicable.