Skip to content

ikigaidojo/ruby-string-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruby String Exercise 1

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!

ruby String Exercise 2

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.

ruby String Exercise 3

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

ruby String Exercise 4

Write a Ruby program to remove last specified characters from a given string.

example

	The entered string was "JavaScript	

output

	JavaScrip

ruby String Exercise 5

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"]

ruby String Exercise 6

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"	

ruby String Exercise 7

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

ruby String Exercise 8

Write a Ruby program to sort a string's characters alphabetically.

example

	Entered string value was "javascript"

output

	aacijprstv

ruby String Exercise 9

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

ruby String Exercise 10

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			

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •