Views: 315
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
Navya
Top Tutorials
492.5K
32K
21.8K
18.7K
18.7K
6.7K
6.6K
4.9K
3.3K
3.1K
Top Questions
18.7K
14.5K
8.3K
6.6K
6.2K
5.7K
4.8K
4.8K
4.3K
3.9K
Top Articles
1.9K
1.6K
946
Top Blogs
795
778
54
Top News
751
683
670
397
382
381