Created
April 1, 2023 16:47
-
-
Save jailsonsf/c7c4bbd38c57d5b1747881fbb0769aaa to your computer and use it in GitHub Desktop.
Desafio Formação Ruby Developer
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
puts 'Digite seu número:' | |
phone_number = gets.chomp | |
whats = '(' << phone_number[0..1] << ') ' << phone_number[2] << ' ' << phone_number[3..6] << '-' << phone_number[7..] | |
if whats.match?(/\(\d{2,}\) \d{1} \d{4,}\-\d{4}/) and phone_number.size == 11 | |
puts "Seu Whatsapp é #{whats}" | |
else | |
puts 'Número inválido' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment