Ruby program to remove vowels from string



Write a Ruby program to remove vowels from string

class RemoveVowelFromString
  def removeVowels
    print "Enter the string: "
    main_string = gets.chomp.downcase
    new_tring = main_string
    vowels = ['a','e','i','o','u']
    vowels.each do |v|
      new_tring = new_tring.gsub(v, "")
    end
    puts "Original string - #{main_string}"
    puts "New string - #{new_tring}"
  end
end

p = RemoveVowelFromString.new 
p.removeVowels

Output:


Enter the string:  umesh kumar kushwaha
Original string - umesh kumar kushwaha
New string - msh kmr kshwh


No comments:

Post a Comment