There are five methods in that we use commonly.
Let us see them in detail :
"Cool Guy"
'u|o'
str = "Cool Guy"
x = str.scan(/u|o/)
puts "The Array elements are : #{x}"
if x
puts "Found a match"
else
puts "Did not find a match"
end
x = str.scan(/u|o/)
str = "Cool Guy"
The Array elements are : ["o", "o", "u"]

str = "Cool Guy"
x = str.match("u|o")
puts "The Match Data is : #{x}"
if x
puts "Found a match"
else
puts "Did not find a match"
end
"Hello Beautiful World"
str = "Hello Beautiful World"
x = str.split("\s")
puts "The Array elements are : #{x}"
x = str.split("\s")The Array elements are : ["Hello", "Beautiful", "World"]

"Hello Beautiful World"
"Hello:Beautiful World"
str = "Hello Beautiful World"
x = str.sub("\s", ":")
puts "The new String is : #{x}"
x = re.sub("\s", ":")
The new String is : Hello:Beautiful World
"Hello Beautiful World"
"Hello:Beautiful:World"
str = "Hello Beautiful World"
x = str.gsub("\s", ":")
puts "The new String is : #{x}"
x = str.gsub("\s", ":")