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

2022-10-22,,,,

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

<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> 

以上这篇java正则表达式,提取双引号中间的部分方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

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

下载本文的Word格式文档,以方便收藏与打印。