我很难找到解决这个问题的办法.如何从字符串中删除第一个字,如下面的字符串.
"i am going to school" "he is going to school" "she is going to school" "they are going to school"
所以字符串可以是任何字符串,不知道第一个单词的确切长度,但只是想删除第一个单词.
结果应如下
"am going to school" "is going to school" "is going to school" "are going to school"
任何帮助?
谢谢
解决方法
"i am going to school".split(' ')[1..-1].join(' ') => "am going to school"
你可以在ruby中的数组中使用两种方法,所以-1是最后一个元素.