我有以下字符串:
str='General Merchandise Stores, Automotive Parts And Accessories Stores, Motor Vehicle Supplies And New Parts Wholesalers, Tire Dealers '
目标是测试下面数组中的字符串是否包含在str
中。我正在运行此代码:
['general merchandise'].any? { |word| str.include?(word) } # => false
字符串在那里。为什么结果为false
?
答案 0 :(得分:0)
如迈克尔回答的那样,它应该通过降低str来工作:
str ='百货商店,汽车零配件商店,汽车用品和新零件批发商,轮胎经销商'
['一般商品']。任何? {| word | str.downcase.include?(word)}#=>真