I have a Matcher for which find() returns true, but despite this, the start(), end(), and group() methods all return IllegalStateException. Here's an extract of the code:
Pattern xmlPattern = Pattern.compile("(<show.*?>.*?</show>)", Pattern.DOTALL);
StringBuffer buf = new StringBuffer("<broadway><show><hi/></show></broadway>");
Matcher m = xmlPattern.matcher(buf);
if (m.find()) {
returnString = m.group(1);
}
Even though m.find() is true, the Matcher behaves as though the pattern hasn't been found: group() throws an IllegalStateException.
Supposedly this shouldn't be possible. Any ideas?