De pipe en het vraagteken

Gevorderde reguliere expressies in R

Angelo Zehr

Data Journalist

Dit of dat

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
Gevorderde reguliere expressies in R

Optioneel maken

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

result of str_view

Gevorderde reguliere expressies in R

Gretig vs. lui

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

result of str_view greedy

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

result of str_view lazy

Gevorderde reguliere expressies in R

Laten we oefenen!

Gevorderde reguliere expressies in R

Preparing Video For Download...