案例:&所需的输出
1) string1 = "Multi Axle Volvo SemiSleeper" => o/p true
2) string2 = "Multi Axle Volvo Semi-Sleeper" => o/p true
3) string3 = "Multi Axle Volvo Semisleeper" => o/p true
4) string4 = "Multi Axle Volvo Semi Sleeper" => o/p true
5) string5 = "Multi Axle Volvo Semi sleeper" => o/p true
6) string6 = "Multi Axle Volvo sleeper" => o/p true
7) string7 = "Multi Axle Volvo sleeper" => o/p true
8) string8 = "Multi Axle Volvo" => o/p false
我需要检查所有字符串' 睡眠者'存在或不存在一个逻辑。
示例:string1 ="多轴沃尔沃SemiSleeper"在这个'睡眠者'这个词存在吗?那么真的是假的....就像这样我写了8个案例......
string1.split(' ').map(&:upcase).include?(SLEEPER) => case failing
string1.split(' ').map(&:upcase).include?(SLEEPER) => case Passing
任何帮助/建议......
答案 0 :(得分:0)
检查大小写'睡眠者'的一种方法。
str = "Multi Axle Volvo SemiSleeper"
str.downcase.include?('sleeper')
=> true