Select parts of a string, given patterns
str_select.Rd
Select parts of a string: before, after or between patterns.
Arguments
- string
A character vector
- after
A character single value (default = NULL), that will be the pattern to select after
- before
A character single value (default = NULL), that will be the pattern to select before
Examples
string <- "begin STRING1 TARGET STRING2 end"
#Select a string, before a pattern
str_select(string,before = "STRING2")
#> [1] "begin STRING1 TARGET"
#Select a string, after a pattern
str_select(string,after = "STRING1")
#> [1] "TARGET STRING2 end"
#Select a string, between two patterns
str_select(string,"STRING1","STRING2")
#> [1] "TARGET"