fork(4) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String fone = "(51)9994-5845";
  13. String cpf = "025.454.644-55";
  14. String cnpj = "02.321.351/0001-35";
  15.  
  16. System.out.println(fone.replaceAll("[^\\d ]", ""));
  17. System.out.println(cpf.replaceAll("[^\\d ]", ""));
  18. System.out.println(cnpj.replaceAll("[^\\d ]", ""));
  19. }
  20. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
5199945845
02545464455
02321351000135