파이프와 물음표

R 중급 정규 표현식

Angelo Zehr

Data Journalist

이것 또는 저것

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
R 중급 정규 표현식

옵션 만들기

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

str_view 결과

R 중급 정규 표현식

탐욕적 vs. 게으른

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

str_view 결과(탐욕적)

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

str_view 결과(게으른)

R 중급 정규 표현식

연습해 봅시다!

R 중급 정규 표현식

Preparing Video For Download...