fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String abc = "02-219 8 53 24";
  10. String hello = abc.replaceAll("\\D+", "");
  11. System.out.println(hello.replaceFirst("^(\\d{3})(\\d{3})(\\d{2})(\\d{2})$", "$1 $2 $3 $4"));
  12. }
  13. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
022 198 53 24