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