DEV Community

Discussion on: Daily Challenge #148 - Disemvowel Trolls

Collapse
 
rburmorrison profile image
Ryan Burmeister-Morrison • Edited

Here's a Ruby submission!

# Remove all vowels ('y' not included) from a string.
#
# @param [String] the string to strip vowels from
#
# @return [String] the resulting string
def disemvowel(str)
  str.split('').select { |ch| !ch.match(/^[aeiou]$/i) }.join('')
end

puts disemvowel("This website is for losers LOL!")
puts disemvowel("No newbies allowed, go to #beginners")
puts disemvowel("LULZ TROLLED")

Here's a link to the Repl.it: repl.it/@rburmorrison/DevToChallen...