Issue
I have regular expressions that allow numbers from 0 to 999999999999999999.99
which is allow
- After a point it will only be two-digit (eg. 151531.99)
- Allow Integer like 1, 2, 3565, 48784, 87848541, 151515
I have found one regex which is [+]?([0-9]*\.[0-9]+|[0-9])
But it does not look above condition.
Solution
This part |[0-9]
is an alternative that matches a single digit.
In this part [0-9]*\.[0-9]+
the digits and to are optional so it can match a leading dot as well.
You can match 1-18 digits and optional dot and 2 digits. Using anchors to prevent a partial match.
^\+?\d{1,18}(?:\.\d{2})?$
Answered By – The fourth bird
Answer Checked By – Terry (BugsFixing Volunteer)