I’m really bad at regex and was wondering if anyone could help me with this. I need to accept a value where $,€, and £ are allowed but not required with a min 5.00 (.00 is not required but is allowed) and 2,000 ( comma is not required but is allowed).
Some examples of valid inputs
$5
€5
£5
$5.00
5
1000
1,000
1,000.00
If you want to allow values like £5.32:
^[$€£]?(\d+([\.,]\d{2})?)$If not:
^[$€£]?(\d+([\.,]00)?)$Once you’ve checked whether it’s formatted correctly using the regex, you can go on to check whether
5 < int(value) < 2000using the first returned group of the regex.EDIT: Having thought about it, here’s a regex which will take care of the bounding too:
^[$€£]?((([1-5],?)?\d{2,3}|[5-9])(\.\d{2})?)$