当前位置:主页 > 软件编程 > JAVA代码 >

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

时间: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> 

您可能感兴趣的文章:

相关文章