Extragerea potrivirilor și a contextului dintr-un text

Expresii regulate intermediare în R

Angelo Zehr

Data Journalist

Mențiuni ale unui nume de companie

"...got to the store. Super smooth and seamless experience. Great value. I would highly recommend ABC Enterprises and I will be coming back for sure! Next, we went..."

Un cuvânt: (\\w+\\s), 0 până la 10 cuvinte: (\\w+\\s){0,10}

str_extract_all(
  blog_post,
  pattern = "(\\w+\\s){0,10}ABC Enterprises\\s?(\\w+\\s){0,10}"
)

Returnează: "I would highly recommend ABC Enterprises and I will be coming back for"

Expresii regulate intermediare în R

Punctuație

"...got to the store. Super smooth and seamless experience. Great value. I would highly recommend ABC Enterprises and I will be coming back for sure! Next, we went..."

Extras: "I would highly recommend ABC Enterprises and I will be coming back for"

Înlocuiți \\w+ cu [\\w[:punct:]]+

Extras: "smooth and seamless experience. Great value. I would highly recommend ABC Enterprises and I will be coming back for sure! Next, we "

Expresii regulate intermediare în R

Să exersăm!

Expresii regulate intermediare în R

Preparing Video For Download...