Skip to content

Instantly share code, notes, and snippets.

@jailsonsf
Created April 1, 2023 16:47
Show Gist options
  • Save jailsonsf/c7c4bbd38c57d5b1747881fbb0769aaa to your computer and use it in GitHub Desktop.
Save jailsonsf/c7c4bbd38c57d5b1747881fbb0769aaa to your computer and use it in GitHub Desktop.
Desafio Formação Ruby Developer
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