I need help.
I have to create a regex for the angularjs ng-pattern attribute. The regular expression should check the text, not every line or some fragments. The text should contain some amounts with exactly 2 decimal places, and each amount should be entered on a new line. In addition, spaces are accepted before and after each amount. If one line contains 2 sums, all text is invalid.
For example, this text is valid because each amount is entered on a new line:
123.34 12345.56 2.54
This example is not valid because one line contains 2 sums:
12.43 123.32 2345.54 124.43
This example is invalid because one sum does not contain 2 decimal numbers (each sum must be exactly 2 decimal places):
123 123.43 123.65
My best attempt is ^(([0-9]+[.][0-9]{2})\s*)+$ , and it can be tested here . But my regular expression is not enough, because it takes text with several sums in one line.
thanks
source share