Ввод — a2b3c1
Вывод — aabbbc
Я использовал следующую программу для решения программы расширения строк.
public class stringExpansionAndCompression {
public void getStringInput() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the String value: ");
String inputStr = reader.readLine();
String output = stringExpansionRegEx(inputStr);
System.out.println(output);
}
public String stringExpansionRegEx(String str) {
StringBuilder result = new StringBuilder();
Pattern pattern = Pattern.compile("([a-zA-Z]\\d)+");
Matcher match = pattern.matcher(str);
boolean bool = Pattern.matches("([a-zA-Z]\\d)+", str);
if (bool = true){
for (int i=0;i
Подробнее здесь: https://stackoverflow.com/questions/790 ... ect-output