Skip to content

Instantly share code, notes, and snippets.

@nuxlli
Created July 14, 2020 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxlli/2195263a242eb8ad6bc51bd110ab1a97 to your computer and use it in GitHub Desktop.
Save nuxlli/2195263a242eb8ad6bc51bd110ab1a97 to your computer and use it in GitHub Desktop.
regex = ~r/^(?:(?<number1>\d{1,}|sn|s\/n)\s*[-,]?\s*)?(?<street>.*?)(?:\s*[-,]?\s*(?<number2>\d{1,}|sn|s\/n))?$/
streets = [
"201 Rua Almirante Calheiros",
"201, Rua Almirante Calheiros",
"201 - Rua Almirante Calheiros",
"sn Rua Almirante Calheiros",
"s/n, Rua Almirante Calheiros",
"Rua Almirante Calheiros 201",
"Rua Almirante Calheiros, s/n",
"Rua Almirante Calheiros - 201",
"Rua Almirante Calheiros - sn",
]
for street <- streets do
Regex.named_captures(regex, street)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment