如何检查字符串是以给定的字符串开始还是结束?似乎没有任何可用的内置方法(或者可能只是我使用的 IDE 没有显示它: RDE)
There are built in methods:
"String".start_with? "S" # true "String".end_with? "4" # false
string.start_with?("substring") string.end_with?("substring")
Returns true or false
Source:
http://ruby-doc.org//core-2.2.0/String.html#method-i-start_with-3F
http://ruby-doc.org//core-2.2.0/String.html#method-i-end_with-3F