I have input strings containing these special characters in any order: *
.
and \n
I want to make sure that there are no other characters in the string and \n
should always be together and not something like *.*..\..n
, so I want to match the string exactly in Java using a regular expression.
I tried using a regular expression to determine if an input string matches the pattern as below:
String input = "*.*.*.\n..";
System.out.println(input.matches("[\\\\.*\\n]"));
However, the output is false.
I tried using the double escape characters, in order to deal with Java's use of escape characters, but the result isn't as expected.