Write a ruby program to lower case, upper case and capitalize all words of a given string.
Example str = "Ruby String Exercises!"
Output will be:
ruby string exercises!
RUBY STRING EXERCISES!
Ruby string exercises!
Write a Ruby program to check whether a string contains a substring.
Example
The entered string was "JavaScript"
The entered substring was "Script"
output
The entered string has the value "JavaScript". Substring "Script" was found in the entered string.
or if not found
The entered string has the value "JavaScript". Substring "<substring value> WAS NOT FOUND in the entered string.
Write a Ruby program to remove all white space within a string.
Example
The entered string was "J a v a S c r i pt"
Output
JavaScript
Write a Ruby program to remove last specified characters from a given string.
example
The entered string was "JavaScript
output
JavaScrip
Write a Ruby program to split a delimited string and convert it to an array.
example
The entered string was "Red, Blue, Green, White, Pink, Orange, Purple, Brown"
output
["Red", "Blue", "Green", "White", "Pink", "Orange", "Purple", "Brown"]
Write a Ruby program to remove a substring from a specified string. Have the value for the string entered through the keyboard. Same as the substring, have the substring value also entered from the keyboard.
example
The entered string was "JavaScript"
The entered substring was "Script"
output
"Java"
Write a Ruby program to count the occurrences of a specified character in a given string.
example
Enter the value "Javascript"
Search the char "J"
output
J1
Write a Ruby program to sort a string's characters alphabetically.
example
Entered string value was "javascript"
output
aacijprstv
Write a Ruby program to trim specific characters from a string.
example
Entered string value was "javasript"
Entered character to trim was "js"
output
avacript
Write a Ruby program the count the number of characters from a string.
example
Entered string was "Ruby, Python, Javascript"
output
The size of the string is 24