标签:
java 正则表达式替换首尾字符或符号
private String replaceStr(String str){ Pattern pattern = Pattern.compile("^,+|,+$"); Matcher matcher = pattern.matcher(str); return matcher.replaceAll(""); } String newStr = replaceStr(",222,3344,344,,,,,"); System.out.println(newStr);//-----222,3344,344
标签:
原文地址:http://my.oschina.net/yongyi/blog/485616