2014-09-19 87 views

回答

3

尝试:

text.include?("â") || text.include?("€") 

OR:

/â|€/.match(text) 
0

我会做这种方式,因为include?方法不带磁盘阵列:

['â', '€'].any? { |char| text.include?(char) } 
+2

一个难得的机会,使用这个快捷方式'[ 'A', '€']任何? &text.method(:include?)' – Santhosh 2014-09-19 06:45:02

+0

无法使用。无论如何,我可以忽略所有使用文字的字母数字字符。命令, – 2014-09-19 07:00:06

+0

它应该工作。 – tompave 2014-09-19 07:02:35

0

我想你”重新使用minitest?您可以使用assert_match

assert_match(/[â€]/, "text with â") 
#=> true 

assert_match(/[â€]/, "text with €") 
#=> true 

assert_match(/[â€]/, "text without") 
#=> MiniTest::Assertion: Expected /[â€]/ to match "text without".