Extraire des correspondances et leur contexte dans un texte

Expressions régulières intermédiaires en R

Angelo Zehr

Data Journalist

Mentions d'un nom d'entreprise

"...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 mot : (\\w+\\s), de 0 à 10 mots : (\\w+\\s){0,10}

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

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

Expressions régulières intermédiaires en R

Ponctuation

"...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..."

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

Remplacez \\w+ par [\\w[:punct:]]+

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

Expressions régulières intermédiaires en R

Passons à la pratique !

Expressions régulières intermédiaires en R

Preparing Video For Download...