I am currently looking for the correct way to write a regular expression for this application:
1 - Number without "." with a length of 1 to 5 digits => /^(\d{1,5})$/
2 - Number with "." with a length of 1 to 5 digits to "." . and 1 to 4 digits after "." or a number starting with "." with a length of 1 to 4 digits after the "." . =>/^(\d{1,5})?\.?(\d{1,4})?$/
I tried using either the "|" operator, but it does not work; (=> /^(\d{1,5})?\.?(\d{1,4})?$|^(\d{1,5})$/
I don’t understand why, this is my first java script regex, and I'm not sure that I use the "|" operator well.
After the answers I would like to get with 1 regex:
123 => ok
12345 => ok
123456 => not ok
12345.2156 => ok
123456.12 => not ok
12345.12345 => not ok
Many thanks for your help. Have a nice day.
Etienne