Condition:
- numbers can be either int or double (total 8 digits)
- numbers can only be separated by spaces (one or many) and commas (0 or one)
- commas can only be inside numbers (there can be no commas at the beginning and end of a line)
- there may be spaces at the beginning of the line (one or many)
- there may be spaces at the end of the line (one or many)
What I do:
([\s]*\d+(\.{1}\d+)?[\s\,\s]+){7}(\d+(\.{1}\d+)?[\s]*){1}
^ this ^
That's ok, except for one condition.
On this string I get true, but need false:
String s1 = " 0 , 4.4 3.2,, 4.1 2 4 1 7.7";
I can't do this:
Numbers can be separated by only one comma or no comma, but in this case there must be a space (one or many).
(?:,?|\s+)for (zero or one comma) or (1 or more spaces)[\s,\s]+with(?:\s*,?\s*|\s+)(assuming a comma can have spaces around it)(?:,|\s+)? Otherwise, the regex would match the empty string.