這是為了實(shí)現(xiàn)去除字符串中重復(fù)字符的功能public class MaxStringLength {public static void main(String[] args) {String s="abcabcb";//答案為3int size = 0;String req = "(?d)(.)(?=.*\\1)";s=s.replaceAll(req, "");for(int i= 0;i < s.length();i++){size += 1;System.out.print(s.charAt(i));}System.out.println();System.out.println(size);}}
請(qǐng)?jiān)敿?xì)講解一下java正則表達(dá)式(?d)(.)(?=.*\\1)?
慕工程0101907
2018-10-28 13:09:14