Try this:
Pattern pattern = Pattern.compile("<h3>(.*)<\\/h3>");
Matcher matcher = pattern.matcher("<h3>Basic Information</h3> <div>");
matcher.find();
StringBuffer sb = new StringBuffer();
matcher.appendReplacement(sb,"$1");
String result = sb.toString();
The reason why you cannot do that with just replaceFirst it's because the appendTail method is called at the end of the replaceFirst method. The matcher will replace the groups you did not specified with empty,the groups you did specified with their value and of course the non-matching bits which well, since no match was created for them, they do not get replaced at all.
In the case of your query:
group 0: <h3>
group 1: Basic Information
group 0: </h3>
non-match: <div>
This is just a generic example of what you can do with the matchers. Of course if you just want the group in specific... Well just use:
matcher.group(1)
replaceAllis really what you want? Perhaps you rather need to extract the match instead of replacing it.