A couple of problems with your code:
String patternString = "\"1\"=\"1\"|^";
It ^should be escaped here, as it ^is a special metacharacter, so do this:
String patternString = "\"1\"=\"1\"|\\^";
Then this call:
boolean matches = matcher.matches();
should be changed to:
boolean matches = matcher.find();
as matchestries to match the complete input line.
source
share