str="我要要要要要要学学学学学学学编编编编编编编编程程程程程程程程程程"
p=re.compile(r"(.)\1+")
s=re.sub(p, "\\1", str)
java跟python类似
s="我要要要要要要学学学学学学学编编编编编编编编程程程程程程程程程程";
s1=s.replaceAll("(.)\\1+","$1");
java外部去分组用$加组号,python是\\加组号
str="我要要要要要要学学学学学学学编编编编编编编编程程程程程程程程程程"
p=re.compile(r"(.)\1+")
s=re.sub(p, "\\1", str)
java跟python类似
s="我要要要要要要学学学学学学学编编编编编编编编程程程程程程程程程程";
s1=s.replaceAll("(.)\\1+","$1");
java外部去分组用$加组号,python是\\加组号