I'd like to check number what it is decimal [17, 2] (0~17 and 0~2).
What is the regular expression for a decimal [17,2]?
For example
1
0.01
0.1
12345678901234567.01
...
I used var regexp = /^\d+(?:\.\d\d?)?$/;
but it can be over 17.
I'd like to check number what it is decimal [17, 2] (0~17 and 0~2).
What is the regular expression for a decimal [17,2]?
For example
1
0.01
0.1
12345678901234567.01
...
I used var regexp = /^\d+(?:\.\d\d?)?$/;
but it can be over 17.
Indeed, your regex doesn't include the 17 limit anywhere.
The regex for "0 to 17 digits" will be:
\d{0,17}
You can read more on repetitions here: https://www.regular-expressions.info/repeat.html