I'm currently working on something where the code inputs about thousands of lines of strings. Each line must follow a specific format like the following:
"Name,#,#,#,#,#,#"
Where 'name' is the name of a movie (we can assume the name won't have any numbers), and # is any number from 0-10. Each value MUST be separated by a comma.
My code is the following:
if (line.matches(".*[a-zA-z].*,([0-9]|10),([0-9]|10),([0-9]|10),([0-9]|10),([0-9]|10),([0-9]|10)")) {
System.out.println("no");
}
else {
System.out.println(line);
The issue is that the title of the film can't have commas in it. If it does, it needs to be printed. However, my 'matches()' doesn't seem to pick up lines that have a comma in the title. It seems to me that my code specifically outlines that if the next entry (separated by a comma) is not an integer, then it does not match, and therefore the 'line' needs to be printed.
Can anyone see where I'm going wrong in this?