If you know that there will only be one set of HTML tags, even better if you knew what tag it was, you might be able to do something like:
String[] html = new String[] {
"<div id=\"option1\">hello</div>",
"<div style=\"color: cyan\">world</div>" };
for(String index : html){
int firstEnd = index.firstIndexOf("/>");
int lastBeginning = index.indexOf("<", 2); // Could become "</div>
String contents = index.substring(firstEnd + 1, lastBeginning - 1);
System.out.println(contents);
}
Please note that I haven't tested this code, nor written it in an IDE, so it may not be entirely correct but I think you can see where I am coming from. Just get the string between the closing ">" of the last tag before the information, and the opening "<" to the closing part of the previous tag...
I can also see that something like this code be modified to handle strings will multiple HTML tags with a bit of imagination...
Alternatively, and I can't believe I didn't think of this to start with, you could use something like the following. Though, again, it is limited to one HTML tag, though I'm sure you could come up with a tag-counting method if needed.
String[] html = new String[] {
"<div id=\"option1\">hello</div>",
"<div style=\"color: cyan\">world</div>" };
String tag = "div";
Pattern p = Pattern.compile("<" + tag + ".*?>(.*?)</" + tag + ">");
Matcher m;
for(String index : html){
m = p.matcher(index);
while(m.find()) System.out.println(m.group(1));
}
HTH