Подскажите что не так, в идее все норм проходит, вывод 12345678
package com.javarush.task.task19.task1913;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
/*
Выводим только цифры
*/
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) {
PrintStream printStream0 = System.out;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream printStream1 = new PrintStream(byteArrayOutputStream);
System.setOut(printStream1);
testString.printSomething();
System.setOut(printStream0);
String text = byteArrayOutputStream.toString();
String result = text.replaceAll("[\\p{Punct}A-Za-z ]","");
System.out.println(result);
}
public static class TestString {
public void printSomething() {
System.out.println("it's 1 a 23 text 4 f5-6or7 tes8ting");
}
}
}