I'm working on a text to HTML parser. I'm using the "@@" notation to mark a Bold character. Ex.
Example @@Bold text in a paragraph
Turns to:
Example <strong>Bold</strong> text in paragraph
The following code works, however I've found out that it works just on the last Bold notation found:
private static String escapeBold(String sCurrentLine) {
if (sCurrentLine.indexOf("@@") < 0) {
return sCurrentLine;
}
String newString = null;
String oldString = null;
String chars[] = sCurrentLine.split(" ");
for (String s : chars) {
if (s.startsWith("@@")) {
newString = "<strong>" + s.replaceAll("@@", "") + "</strong>";
oldString = s;
}
}
return (sCurrentLine.replaceAll(oldString, newString));
}
Is there a simpler way to do it, maybe with a RegExpr ? Thanks!