正則表達式提取雙引號之間的內容,當然了可以找到就可以實現替換了。
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