Extrahera träffar och omgivning från en text

Reguljära uttryck på mellannivå i R

Angelo Zehr

Data Journalist

Omnämnanden av ett företagsnamn

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

Ett ord: (\\w+\\s), 0 till 10 ord: (\\w+\\s){0,10}

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

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

Reguljära uttryck på mellannivå i R

Interpunktion

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

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

Ersätt \\w+ med [\\w[:punct:]]+

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

Reguljära uttryck på mellannivå i R

Nu kör vi en övning!

Reguljära uttryck på mellannivå i R

Preparing Video For Download...