Pattern matching with regular expressions : match « String « Ruby
- Ruby
- String
- match
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
Related examples in the same category