None
None

Reputation: 9247

Regex to Allow various currency formats

I have this regex:

[0-9]+,[0-9]{2}

https://regexr.com/3joum

And i can enter

10,00
1,00,
100,00,
1000,00

But i also want to have this:

1.000,00
10.000,00
100.000,00
1000.000.00

and so on... to that be valid also. Any suggestions?

Upvotes: 0

Views: 36

Answers (1)

cptwonton
cptwonton

Reputation: 468

It's kind of hard to tell what rules exactly you're looking to follow with your regex. How about this?

([0-9]+[,.])+[0-9]{2}(,)?

This regex will allow you to match currency that uses either a , or a . and can even end in a , like in some of your examples.

Upvotes: 1

Related Questions