Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby match word in string

text = "A regular expression is a sequence of characters that define a search pattern."

puts 'Found "A" at the beginning of the string.' if text.match(/^A/)
puts 'Found "O" at the beginning of the string.' if text.match(/^O/)

puts 'Found the string "character".' if text.match(/character/)
puts 'Found the word "character".' if text.match(/character/)
Source by ruby-for-beginners.rubymonstas.org #
 
PREVIOUS NEXT
Tagged: #ruby #match #word #string
ADD COMMENT
Topic
Name
5+1 =