Pipa dan tanda tanya

Ekspresi Reguler Tingkat Menengah di R

Angelo Zehr

Data Journalist

Ini atau itu

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
Ekspresi Reguler Tingkat Menengah di R

Membuat bagian opsional

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

hasil str_view

Ekspresi Reguler Tingkat Menengah di R

Rakus vs. malas

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

hasil str_view greedy

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

hasil str_view lazy

Ekspresi Reguler Tingkat Menengah di R

Ayo berlatih!

Ekspresi Reguler Tingkat Menengah di R

Preparing Video For Download...