Extraindo correspondências e entorno de um texto

Expressões Regulares Intermediárias em R

Angelo Zehr

Data Journalist

Menções ao nome de uma empresa

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

Uma palavra: (\\w+\\s), de 0 a 10 palavras: (\\w+\\s){0,10}

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

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

Expressões Regulares Intermediárias em R

Pontuação

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

Extraído: "I would highly recommend ABC Enterprises and I will be coming back for"

Substitua \\w+ por [\\w[:punct:]]+

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

Expressões Regulares Intermediárias em R

Vamos praticar!

Expressões Regulares Intermediárias em R

Preparing Video For Download...