Skip to content

Instantly share code, notes, and snippets.

@chiragmongia
Created July 31, 2013 06:44
Show Gist options
  • Select an option

  • Save chiragmongia/6119869 to your computer and use it in GitHub Desktop.

Select an option

Save chiragmongia/6119869 to your computer and use it in GitHub Desktop.
#Question - Replace - Regex
#Ask user to enter text. Replace each vowel in the text with a '*' using regular expression.
def replace_vowels_with_asterisk(input_text)
input_text.gsub(/[aeiou]/i, '*')
end
#Main
puts "Replacing Vowels with '*'"
puts "Enter the text"
input_text = gets.chomp
puts "---Text after replacing vowels--"
puts replace_vowels_with_asterisk(input_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment