- CPF
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/
- CNPJ
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
- Both
/(^\d{3}\.\d{3}\.\d{3}\-\d{2}$)|(^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$)/
- Ruby
'256.515.510-77'.match? /\d{3}\.\d{3}\.\d{3}\-\d{2}$/
# ou
is_license_plate_like = ->(value) { value =~ /\A[A-Z]{3}-?\d[0-9A-Z]\d{2}\z/i }
is_cpf_like = ->(value) { value =~ /\A\d{3}.?\d{3}.?\d{3}-?\d{2}\z/i }
is_cnpj_like = ->(value) { value =~ %r{\A\d{2}\.?\d{3}\.?\d{3}/?\d{4}-?\d{2}\z}i }