match operator demo : Match Operator « Development « Ruby






match operator demo


puts name = "this is a test" 
puts name =~ /a/ # 1 
puts name =~ /z/ # nil 
puts /a/ =~ name # 1 

 








Related examples in the same category

1.match operators return the character position at which the match occurred.