If your intention is to leave the string only with the numbers use:
String fone = "(51)9994-5845";
String cpf = "025.454.644-55";
String cnpj = "02.321.351/0001-35";
System.out.println(fone.replaceAll("[^\\d ]", ""));
System.out.println(cpf.replaceAll("[^\\d ]", ""));
System.out.println(cnpj.replaceAll("[^\\d ]", ""));
Using negation and different values of numeric digits ( d), all different characters of numbers will be removed from the string. This avoids the need to keep adding restrictions to hyphens, parentheses, dots, etc...
In short, you want only the numbers?
– Randrade
Yes only the numbers, @Randrade
– rodrigo.oliveira