Roura a otazník

Intermediate Regular Expressions in R

Angelo Zehr

Data Journalist

Jedno nebo druhé

lines <- c(
  "Karate Kid 2, Distributor: Columbia, 58 Screens",
  "Finding Nemo, Distributors: Pixar and Disney, 10 Screens",
  "Finding Harmony, Distributor: Unknown, 1 Screen",
  "Finding Dory, Distributors: Pixar and Disney, 8 Screens"
)
str_detect(lines, "Columbia|Pixar")
TRUE TRUE FALSE TRUE
Intermediate Regular Expressions in R

Volitelné prvky

str_view(lines, pattern = "Distributor|Distributors")
str_view(lines, pattern = "Distributors?")

výsledek str_view

Intermediate Regular Expressions in R

Greedy vs. lazy

str_view("Toy Story 3 In Disney Digital 3D", ".*3")

výsledek str_view – greedy

str_view("Toy Story 3 In Disney Digital 3D", ".*?3")

výsledek str_view – lazy

Intermediate Regular Expressions in R

Pojďme si procvičit!

Intermediate Regular Expressions in R

Preparing Video For Download...