I am going to use the following method to replace special BB Codes for html links
public String replace(String text , String bbcode , String imageLocation ){
StringBuffer imageBuffer = new StringBuffer ("");
Pattern pattern = Pattern.compile("\\"+bbcode );
Matcher matcher = pattern.matcher(text);
StringBuilder builder = new StringBuilder();
int i = 0;
while (matcher.find()) {
//String orginal = replacements.get(matcher.group(1));
imageBuffer.append("<img src=\"" + imageLocation + "\" />");
String replacement = imageBuffer.toString();
builder.append(text.substring(i, matcher.start()));
if (replacement == null) {
builder.append(matcher.group(0));
} else {
builder.append(replacement);
}
i = matcher.end();
}
builder.append(text.substring(i, text.length()));
return builder.toString();
}
but when it comes to replacing the following bbcodes ,
:D
O:-)
:-[
:o)
:~(
:xx(
:-]
:-(
^3^
@_@
:O
:)
:P
;-)
???
?_?
Z_Z
It turns out to be not closing bracket and : <-- not recognized
How should I override the regex functional code and replace the abovementioned list of icons as html image links?
I am currently using this string array but It comes out with the following error error: Error: No resource type specified (at '^index_6' with value '@_@').
<string-array name="hkgicon_array">
<item>[369]</item>
<item>#adore#</item>
<item>#yup#</item>
<item>#ass#</item>
<item>:-(</item>
<item>^3^</item>
<item>@_@</item>
</string-array>