Skip to contents

Actually Extract All Patterns

Usage

strg_extract_all(str, pattern)

Arguments

str

A string or vector of strings

pattern

A regex pattern. If you want to extract multiple terms, use the regex or operator. (For 'one' or 'two': one|two)

Value

A list of matches the same length as str. Each list item will contain all matches.

Examples

c(
  'oneightwo',
  '1two3four'
) |>
  strg_extract_all('one|two|three|four|five|six|seven|eight|nine|[1-9]')
#> [[1]]
#> [1] "one"   "eight" "two"  
#> 
#> [[2]]
#> [1] "1"    "two"  "3"    "four"
#>