私は以下のサンプルテキストを持っており、機械学習のみを抽出します。Rでは、フォーメーションに関係なく、テキストから特定の単語をマッチして抽出する方法は?
text <- c("Machine Learning is my fav topic.", "I love machinelearning.")
ifelse((found <- regexpr("\\sMachine Learning", text,
perl =TRUE)) !=-1, substring(text, found,
found+attr(found,"match.length")), "nothing found")
しかし、それは私を返します。..
"nothing found" "nothing found"
私はその結果を取得する必要があります(?i)
は、正規表現の場合は鈍感
"Machine Learning", "machinelearning"