正则表达式提取双引号之间的内容,当然了可以找到就可以实现替换了。
1 2 3 4 5 6 7 8 9 |
<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正则表达式,提取双引号中间的部分方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
原文链接:https://blog.csdn.net/wzjin/article/details/78661702
查看更多关于Java正则表达式,提取双引号中间的部分方法的详细内容...