As I can make a regular expression that accepts up to 10 integers a point and up to 10 decimal places, I have the following regular expression, but it does not work it only works with decimals
/^([0-9]{0,10})+\.?[0-9]{0,10})$/
As I can make a regular expression that accepts up to 10 integers a point and up to 10 decimal places, I have the following regular expression, but it does not work it only works with decimals
/^([0-9]{0,10})+\.?[0-9]{0,10})$/
Hi, you can use this regular expression:
/^(\d{1,10})(\.\d{1,10})?$/
\ d is equivalent to [0-9]
I will explain the expression that consists of two parts.
^(\d{1,10})
With the expression above we are telling you to accept 1 to 10 numbers at the beginning of the string
(\.\d{1,10})?$
With the expression above we are telling you to accept a point followed by 1 to 10 numbers and with the question mark we are saying that it may or may not come what we have inside the parentheses, finally with the sign of $ le We indicate that it is the end of our chain.
To test regular expressions I recommend it page supports JavaScript & PHP / PCRE RegEx, to test the regular expression, put it in the following way:
^(\d{1,10})(\.\d{1,10})?$
And where it says text enter the numbers to test.