次のような文があるとします。
The quick brown fox jumps over the lazy dog
「ジャンプ」を含め、前にすべてを切り取りたいので、次のように残します。
over the lazy dog
現在、削除したいパーツのインデックスを取得し、そのパーツの長さを追加して、次のようにスライスします。
sentence = "The quick brown fox jumps over the lazy dog"
slice_index = sentence.index("jumps").to_i + sentence.size
sliced_sentence = sentence.slice(slice_index..-1)
これを達成するためのより良い方法はありますか?
ありがとう!