Answers for "ruby string match"

1

ruby regexp match all

# use scan
"hello".scan(/l/)
Posted by: Guest on October-07-2021
2

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\b/)
Posted by: Guest on October-27-2020
0

ruby match all

string.scan(/regex/)
Posted by: Guest on March-01-2021

Browse Popular Code Answers by Language