Answer the question
In order to leave comments, you need to log in
How to make a regular expression for the string 11.22-+2222.22-+333.22-+44.22?
The next line is 11.22-+2222.22-+333.22-+44.22
1) the numbers before the dot can be in the amount from 1 to 4.
2) the numbers after the dot can be in the amount from 0 to 2. Accordingly, you can’t end with a dot either.
3) there can only be + or - between numbers. Two characters in a row are prohibited.
4) the whole line can only end with a number.
5) the line can contain from 1 to 4 numbers. For example (11.22 or 11.22-2222.22 or 11.22+2222.22-333.22 or 11.22-2222.22+333.22-44.22).
I get only a non-working horror in the form -
/((^\d*$)|(^\d*\.\d{0,2}$))|(?:((^(\+?|\-?)$)\d*\.\d{0,2}$)|((^(\+?|\-?)$)\d*$))?(?:((^(\+?|\-?)$)\d*\.\d{0,2}$)|((^(\+?|\-?)$)\d*$))/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question