import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] argv) throws Exception {
String patternStr = "<(\\S+?).*?>(.*?)\\1>";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher("");
// Set the input
matcher.reset("xx yy zz");
// Get tagname and contents of tag
boolean matchFound = matcher.find();
String tagname = matcher.group(1);
String contents = matcher.group(2);
matcher.reset("xx yy ");
matchFound = matcher.find();
}
}