私のコードはここにあります
str= "In 2004, Obama received national attention during his campaign to represent Illinois in the United States Senate"
arr =str.scan(/\S+(?:\s+\S+)?/)
it gives
arr=["In 2004,", "Obama received", "national attention", "during his", "campaign to", "represent Illinois", "in the", "United States", "Senate"]
fresh_arr=[]
arr.each do |el|
if !arr.match(/is|am|are|this|his/)
fresh_arr << el
end
end
今、私は(is、am、are、this、his)タイプの文字列を含む要素を削除したいので、次のような結果になります
arr=["Obama received", "national attention","represent Illinois","United States", "Senate"]
非常に大きなデータがあり、6 秒かかります。別の方法でこれを行うことはできますか