2

Validação de CPF e CNPJ - Java

 1 year ago
source link: https://gist.github.com/rdakar/bbcf2262db572ddffd65ba26ddd42e80
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Validação de CPF e CNPJ

Instantly share code, notes, and snippets.

Validação de CPF e CNPJ - Java

Na linha 37 deveria ser:
cnpj = cnpj.trim().replace(".", "").replace("-", "").replace("/", "");

melhor usar regular expression pra remover os caracteres não numéricos, o código fica mais limpo.

Na linha 24:
cpf = cpf.trim().replaceAll("\D", "");

Na linha 37:
cnpj = cnpj.trim().replaceAll("\D", "");


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK