Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(\w+(\s+\w+)*),\s?(\d+)\s+-\s+([\w-\s:]+(\s+\w+)*-?[\w+\s+:;]),\s?(\w+(\s+\w+)*)\s?-?\s?(\w+(\s+\w+)*),\s?(\w{2,})$
/
g

Description

Extract address parts from a Brazil Addressess (Logradouro/Street, Numero/Number, Complemento/Complement, Bairro/Neighborhood, Cidade/City, Estado/State)

Submitted by Glauber Portella <glauberportella@gmail.com> - 7 years ago