I am doing a Pattern match the matcher.matches is coming as false, while the matcher.replaceAll actually finds the pattern and replaces it. Also the matcher.group(1) is returning an exception.
@Test
public void testname() throws Exception {
Pattern p = Pattern.compile("<DOCUMENT>(.*)</DOCUMENT>");
Matcher m = p.matcher("<RESPONSE><DOCUMENT>SDFS878SDF87DSF</DOCUMENT></RESPONSE>");
System.out.println("Why is this false=" + m.matches());
String s = m.replaceAll("HEY");
System.out.println("But replaceAll found it="+s);
}
I need the matcher.matches() to return true, and the matcher.group(1) to return "<DOCUMENT>SDFS878SDF87DSF</DOCUMENT>"
Thanks in advance for the help.