I think this is the pattern for <b> tags
<b\b[^>]*>(.*?)</b>
and
this is for general HTML tags
<([A-Z][A-Z0-9]*)\b[^>]*>.*?</\1>
but if I write something like
String S4 = "I am <b>bold</b> and I am <i>italic</i> and I am <b><i>bold italic</i></b>"
Pattern htmlTag = Pattern.compile("<([A-Z][A-Z0-9]*)\b[^>]*>.*?</\1>");
int length = s4.length();
Matcher matcher = pbold.matcher(s4);
String result = matcher.group();
I need to get the output to String array
like
String[] sa;
and sa should contain {"I am", "bold", "and I am","italic","and I am","bold italic"}
I konow I can get this but after storing in string array I need to differentiate that sa[1] was between bold tags and sa[3] was in italic tags and sa[5] was in bold italic tags.
Is there any way to do this.
Right now I am parsing the string character by character and doing it bu tI need something more generic as it is difficult to have nested tags with character logic.
Please help