I need some help.
I have to construct a regex for angularjs ng-pattern attribute.
The regex has to validate a text, not each line or some pieces. The text has to contains some amounts with exactly 2 decimals and each amount should be entered in the new line. Also, spaces are accepted before and after each amount.
If one line contains 2 amount then the entire text is not valid.
For example this text is valid because each amount is entered in the new line:
123.34
12345.56
2.54
This example is not valid because one line contains 2 amounts:
12.43
123.32 2345.54
124.43
This example is not valid because one amount does not contains 2 decimal(each amounts has to be with exactly 2 decimals):
123
123.43
123.65
My best try is ^(([0-9]+[.][0-9]{2})\s*)+$ and it can be tested here. But my regex it's not enough because it accept text with multiple amounts in the same line.
Thanks
^\d+\.\d{2}(?:\r?\n\d+\.\d{2})*$if not, see regex101.com/r/E5l3SB/1 demo./^[^\S\r\n]*\d+\.\d{2}(?:[^\S\r\n]*\r?\n[^\S\r\n]*\d+\.\d{2})*[^\S\r\n]*$/.ng-trim.