导入类
java.util.regex.Pattern
java.util.regex.Matcher
java.lang.StringBuffer
java.lang.System
完整代码:
java{
String content = "测试内容: http://www.1.com
http://www.2.com";
Pattern pattern = Pattern.compile("(https?://\S+)");
Matcher matcher = pattern.matcher(content);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(sb, "$1");
}
matcher.appendTail(sb);
gj.sc(sb.toString());
}
暂无评论