const cpfMask = (cpf) => { if (/[a-zA-Z]|\W/.test(cpf)) { return cpf.replace(/[a-zA-Z]|\W/, ""); } return cpf.replace(/^([0-9]{3})\.?([0-9]{3})\.?([0-9]{3})\-?([0-9]{2})$/, "$1.$2.$3-$4"); }