public static void main(String[] args) {
String strContent="请到以下地址查询:查询地址:充值地址:https://pay.sdo.com/Index.aspx?type=card尊敬的用户: 您好,该卡帐号和密码是正确的,请到以下https://pay.sdo.com/Index.aspx?type=card 地址查询:查询地址:充值地址:https://pay.sdo.com/Index.aspx?type=card ";
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("\" target=\"_blank\">"+urlStr+"
");matcher.appendReplacement(result, replace.toString());
}
matcher.appendTail(result);
System.out.println(result);
}