Description Usage Arguments Details Value Author(s) Examples
This function extracts substring(s) which match a given pattern.
1 |
x |
Character vector. |
pattern |
Regular expression. |
sep |
Character string which separates the fields. |
mult |
Logical, if multiple matching fields should be returned, or otherwise NA. |
unlist |
Logical, unlists multiple results. |
cores |
Integer for number of computational cores to use. |
The function is deprecated and will be removed with miscset
version 2.
It is recommended to use str_extract or
str_extract_all instead.
A list of character vectors containing the substrings that are
matching pattern
and are separated by sep
or NA
if
the pattern could not be found.
Sven E. Templer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #
library(stringr)
s <- c("A1 B1 C1","A2 B2", "AA A1", "AA", "B1 A1", "BB AB A1")
strextr(s, "^[AB][[:digit:]]$") # deprecated
str_extract(s, "[AB][:digit:]")
strextr(s, "^[AB][[:digit:]]$", mult = TRUE) # deprecated
str_extract_all(s, "[AB][:digit:]")
strextr(s, "^[AB][[:digit:]]$", mult = TRUE, unlist = TRUE) # deprecated
unlist(str_extract_all(s, "[AB][:digit:]")) # has no <NA> values
strextr(s, "^[C][[:digit:]]$") # deprecated
str_extract(s, "[C][:digit:]")
#
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.