Ruby 使用.include忽略字符串中的大小写?
在本节目中:Ruby 使用.include忽略字符串中的大小写?,ruby,Ruby,在本节目中: thisstring = "sample text" if thisstring.include? "sample TEXT" puts "heres some output" end 有没有一种方法可以使用casecmp忽略文本中的大写字母?这是怎么回事 if thisstring.downcase.include?("sample TEXT".downcase) puts "heres some output" end 或: 这个怎么样 if thisstring
thisstring = "sample text"
if thisstring.include? "sample TEXT"
puts "heres some output"
end
有没有一种方法可以使用casecmp忽略文本中的大写字母?这是怎么回事
if thisstring.downcase.include?("sample TEXT".downcase)
puts "heres some output"
end
或:
这个怎么样
if thisstring.downcase.include?("sample TEXT".downcase)
puts "heres some output"
end
或:
由于
include?
的参数与thisstring
的参数相同,不涉及大小写,因此如果thisstring==“sample TEXT”,则更容易看到。顺便说一句,虽然我想这是对南方公园和克林格沃西的暗示,是的,你可以选择至少10**100个其他用户名中的任何一个。因为include?
的参数在不考虑大小写的情况下与thisstring
相同,如果thisstring==“sample TEXT”
,则更容易看到。顺便说一句,虽然我想这是对南方公园的暗示,而且是的,你可以选择至少10**100个其他用户名中的任何一个。