Regular Expressions 101

Community Patterns

1...56789...173

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^(\d{3})\.?(\d{3})\.?(\d{3})\-?(\d{2}$)$|^(\d{2})\.?(\d{3})\.?(\d{3})\/?([0-1]{4})\-?(\d{2})$
/

Description

Valida se é um CPF ou um CNPJ válido, independente da máscara

Submitted by Victor A. de O. Neto - 9 years ago