I have a pattern using ^ and $ to indicate the beginning and end of a line.
Pattern pattern = Pattern.compile( "^Key2 = (.+)$" );
and enter the following:
String text = "Key1 = Twas brillig, and the slithy toves" + "\nKey2 = Did gyre and gimble in the wabe." + "\nKey3 = All mimsy were the borogroves." + "\nKey4 = And the mome raths outgrabe.";
But pattern.matcher( text ).find() returns false .
Doesn't that work? The template class documentation in the summary states:
Boundary matchers
^ The beginning of a line
$ The end of a line
java regex
Andy Thomas
source share