ytechie wrote:Can you share the regexp mod? I would love to learn something new!
Hi, sure! But before i release the final mod i will fix some bugs in the interface.
about this Mod: I use this function with this simple Regexp in ChatService.java:
- Code: Select all
private String ReplaceUrl(String message) {
Pattern patt = Pattern.compile("(?<!\\S)(((f|ht){1}tp[s]?:\\/\\/|(?<!\\S)www\\.)[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]+)");
Matcher matcher = patt.matcher(message);
if(matcher.find()){
if (matcher.group(1).startsWith("http://")){
return matcher.replaceAll("<a href=\"$1\" target=_blank>$1</a>");
}else{
return matcher.replaceAll("<a href=\"http://$1\" target=_blank>$1</a>");
}
}else{
return message;
}
}
I found out that you can use the dwr framework to escape the HTML Code
- Code: Select all
dwr.util.setEscapeHtml(false);
or
- Code: Select all
dwr.util.setValue('x', "<b>Hi</b>", { escapeHtml:false });
.. for my use the Regexp works fine.
best regards
