I have a String like this
String s = "AZERTY<em>ZA</em> QWERTY OK <em>NE</em>NO ;
I want extract strings between and and construct a StringBuilder with all parts of the string in right order. I do this because i need to identify and localize the strings extracted but i need to keep the entire string too. The purpose for all this work is to add later the entire String in a excel sheet cell and add font for the string between
XSSFRichTextString xssfrt = new XSSFRichTextString(); // acts like a StringBuilder
xssfrt .append("AZERTY");
xssfrt .append("ZA" , font); //extract 1
xssfrt .append(" QWERTY OK "); // keep spaces
xssfrt .append("NE" , font); //extract 2
xssfrt .append("NO");
There is my regex which can extract the desired strings but i don't know how to construct the StringBuilder with all parts in right order :/
Pattern p = Pattern.compile("\\<em>(.*?)\\</em>");
Matcher m = p.matcher(value);
while(m.find())
{
m.group(1); //extracts
}
Thank you very much