Mega Code Archive

 
Categories / Ruby / String
 

Pattern matching with regular expressions

s = "hello" s =~ /[aeiou]{2}/    # => nil: no double vowels in "hello" s.match(/[aeiou]/) {|m| m.to_s} # => "e": return first vowel