pls help me.
how can I split this String value?
my code below wont work:
String[] tempStr;
toSplit = "This is the just a sample <FONT COLOR=BLACK>1)[option1/option2]</FONT> sentence. This is another sample <FONT COLOR=BLUE>1)[othertext1/othertext2]</FONT> sentence."
tempStr = toSplit.split("<FONT COLOR = [A-Z]*>([.])*</FONT>");
what i want guys is to split the paragraph with the delimiter …. thanks for any help.
It depends how would you like to split. If you need to extract the text fragments as a array elements and remove all HTML tags you can say something like the following:
tempStr = toSplit.split("<FONT.*?</FONT>");Pay attention. I do not write all attributes of FONT tag. It is not needed here. My expression is simpler and do not have to care about spaces, quotes etc.
But this regex is case sensitive. To be more flexible and be able to use various flags supported by Pattern use java.util.Pattern, create Matcher and then use its split() method.
BTW if your parsing may be more complicated I’d recommend you to use “real” html parser.