Created
July 14, 2020 13:03
-
-
Save nuxlli/2195263a242eb8ad6bc51bd110ab1a97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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