Ruby/String/matching operator

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

if a string contains any vowels:

puts "String has vowels" if "This is a test" =~ /[aeiou]/



=~ is a matching operator

puts "String contains no digits" unless "This is a test" =~ /[0?]/