FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 156   



Following program shows you how to replace spaces with hyphen in a string.
In this program we use .gsub to replace spaces with hyphen

input  = "Hello World"
result = input.gsub(" ", "-")
puts "After replacing input string with - is: #{result}"

Output:

After replacing input string with - is: Hello-World



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News