字节字符匹配
题目
三个连续的替换成两个,
AABB替换成AAB
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine(); //去掉多余的空行
while(n > 0){
n--;
String s = sc.nextLine();
String res = s.replaceAll("(.)\\1+","$1$1").replaceAll("(.)\\1(.)\\2","$1$1$2");
System.out.println(res);
}
}
}