日期:2014-05-20 浏览次数:20869 次
public static void main(String[] args) {
//String reg="@^(\\.|\\,|:|;|!|\\?|\\s|#|@|。|,|:|;|!|?)*";
String reg="@[^\\.^\\,^:^;^!^\\?^\\s^#^@^。^,^:^;^!^?]+"; //以@开头以.,:等结束的字符串
Pattern pattern=Pattern.compile(reg);
System.out.println(pattern.toString());
Matcher matcher=pattern.matcher("fsafaf加大@梵净山,金佛山@就佛网 杰弗里斯");
StringBuffer sb=new StringBuffer();
while(matcher.find()){
System.out.println(matcher.group());
matcher.appendReplacement(sb, "<a href='abc'>"+matcher.group()+"</a>");
}
matcher.appendTail(sb);
System.out.println(sb);
}