久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      用Java正則去掉字符串中重復(fù)出現(xiàn)的字符

      String str = “abcdeabcdeabcdeaaaaaadddddceeeeabcccccccacadaeec”;
      str = str.replaceAll(reg, “”);
      System.out.println(str);

      str = str.replaceAll(“(?s)(.)(?=.*\1)”, “”);
      (?s)(.)(?=.*1)

      (?s) 開啟單行模式 DOTALL 讓. 號(hào)匹配任意字符
      (.) 任意字符 并捕獲在第一組
      (?=.*1) 這是斷言, 表示后面內(nèi)容將是 任意個(gè)字符加上第一組所捕獲的內(nèi)容

      這樣子,如果這整個(gè)式子匹配到,表示,第一個(gè)捕獲組內(nèi)容在字符串中,至少出現(xiàn)兩次,替換為 “” 空串.

      進(jìn)行 全局替換后, 整個(gè)字符串所出現(xiàn)的字符將不重復(fù)。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)