Rで学ぶ中級正規表現
Angelo Zehr
Data Journalist
"…店に着いた。とてもスムーズでシームレスな体験。お得でした。ABC Enterprises を強く勧めます。必ずまた来ます! その後、私たちは…"
1語: (\\w+\\s), 0〜10語: (\\w+\\s){0,10}
str_extract_all(
blog_post,
pattern = "(\\w+\\s){0,10}ABC Enterprises\\s?(\\w+\\s){0,10}"
)
戻り値:
"I would highly recommend ABC Enterprises and I will be coming back for"
"…店に着いた。とてもスムーズでシームレスな体験。お得でした。ABC Enterprises を強く勧めます。必ずまた来ます! その後、私たちは…"
抽出結果:
"I would highly recommend ABC Enterprises and I will be coming back for"
\\w+ を [\\w[:punct:]]+ に置換
抽出結果:
"smooth and seamless experience. Great value. I would highly recommend ABC Enterprises and I will be coming back for sure! Next, we "
Rで学ぶ中級正規表現