3
I would like a regular expression (REGEX) to format the CPF or CNPJ field
This is the code I’ve come up with so far:
    String cpf ="09551130401";
    cpf = cpf.replaceAll("(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})", "$1.$2.$3-$4");
    System.out.println(cpf);