您的位置:首页 > Web前端

特殊字符导致用正则表达式进行字符串替换失败,Java replaceAll()方法报错Illegal group reference

2015-10-05 16:09 1041 查看
String str = "给商品||?>\\n阳澄湖大闸蟹!@#$%^&*()_+-=?:\",.]\\|~.,\/??\\\\|\\br点赞"


String tradeDescription = "||?>\\n阳澄湖大闸蟹!@#$%^";
String description = "给商品 #goodsName# 点赞";
String result = description.replaceAll("#goodsName#", Matcher.quoteReplacement(CommonUtil.toString(tradeDescription)));


参考:
http://www.colabug.com/thread-1131948-1-1.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: