Answer the question
In order to leave comments, you need to log in
How to change the output?
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Task2 {
public static void main(String[] args) {
String text = "ZAAABBCCDDDD";
Matcher m = Pattern.compile("(.)\\1+").matcher(text);
while (m.find()) {
String sub = m.group();
System.out.println(sub + sub.length ());
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question