时间:2021-06-06 08:49:42 | 栏目:JAVA代码 | 点击:次
正则表达式提取双引号之间的内容,当然了可以找到就可以实现替换了。
<code class="language-java">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);</code>