Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2023-02-18 17:28
Updated·2023-02-18 17:40
Flavor·Java

"
(\d){3}\.?\1{3}\.?\1{3}-?\1{2}
"
gm
Open regex in editor

Description

It matches CPF (Cadastro de Pessoa Física) with all digits as the same number.

Since CPF consists in a pattern ###.###.###-##, or ###########, and # being a single digit, this document cannot have all the 11 (eleven) digits as the same number. Therefore 000.000.000.000-00 would not be an example of a CPF, since all 11 digits are the same number, in this case 0 (zero). This regular expression matches this case, where the cpf have all digit as the same number.

Submitted by TheRockSaysOP