给非a标签外部链接加上跳转

ė 113 6 0
本文最近更新于23.01.14 周六请自行判断新内容
String regex = "(http:|https:)//[^[A-Za-z0-9\\._\\?%&+\\-=/#]]*";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(strContent);
StringBuffer result = new StringBuffer();
while (matcher.find()) {
String urlStr = matcher.group();
StringBuffer replace = new StringBuffer();
replace.append("<a href="\&quot;&quot;).append(urlStr);" target="\&quot;_blank\&quot;">"+urlStr+"</a>");
matcher.appendReplacement(result, replace.toString());
}
matcher.appendTail(result);
System.out.println(result);
栖息邦 收藏Ctrl+D 转载注明来源
管理员登录
注册

提示:点击上下面区域关闭

字号调整

View My Stats
空位 空位
本次加载耗时:0.286s