private String changeUrl(String content){
String regex = "(http:|https:)//[^[A-Za-z0-9\\._\\?%&+\\-=/#]]*";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(content);
StringBuffer result = new StringBuffer();
while (matcher.find()) {
String urlStr=matcher.group();
StringBuffer replace = new StringBuffer();
replace.append("<a href=\""+urlStr+"\"");
replace.append(" onClick=\""+"window.open('"+urlStr+"')\""+">"+urlStr+"</a>");
matcher.appendReplacement(result, replace.toString());
}
matcher.appendTail(result);
System.out.println(result);
return result.toString();
}