Java正则表达式, 提取双引号中间的部分

来源:互联网 发布:淘宝买多少单有一颗心 编辑:程序博客网 时间:2024/06/06 17:56


正则表达式提取双引号之间的内容,当然了可以找到就可以实现替换了。


String str="this is \"Tom\" and \"Eric\", this is \"Bruce lee\", he is a chinese, name is \"李小龙\"。"; Pattern p=Pattern.compile("\"(.*?)\"");Matcher m=p.matcher(str);int i=0;while(m.find()){                            str=str.replace(m.group(),""+(i++));}System.out.println(str);