I'm trying to check if each line is equal to "test". When I try to run the following code, I expect the result to be true, because every line is exactly "test". Yet, the result is false.
// Expected outcome:
// "test\ntest\ntest" - should match
// "test\nfoo\ntest" - should not match
// "test\ntesttest\ntest" - should not match
Pattern pattern = Pattern.compile("^test$", Pattern.MULTILINE);
Matcher matcher = pattern.matcher("test\ntest");
System.out.println(matcher.matches()); // result is false
What am I missing here? Why is the result false?