Alternation

  • Defined by |: to pick between one or more alternative patterns.
# look for fruits containing “apple”, “melon”, or “nut”
str_view(fruit, "apple|melon|nut")
##  [1] │ <apple>
## [13] │ canary <melon>
## [20] │ coco<nut>
## [52] │ <nut>
## [62] │ pine<apple>
## [72] │ rock <melon>
## [80] │ water<melon>
# look for a repeated vowel
str_view(fruit, "aa|ee|ii|oo|uu")
##  [9] │ bl<oo>d orange
## [33] │ g<oo>seberry
## [47] │ lych<ee>
## [66] │ purple mangost<ee>n