strextr: Extract a Substring

Description Usage Arguments Value Author(s) Examples

Description

This function extracts substring(s) which match a given pattern.

Usage

1
strextr(x, pattern, sep = " ", mult = F, unlist = F, cores = 1)

Arguments

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.

Value

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.

Author(s)

Sven E. Templer

Examples

1
2
3
4
5
6
7
8
9
#

s <- c("A1 B1 C1","A2 B2", "AA A1", "AA", "B1 A1", "BB AB A1")
strextr(s, "^[AB][[:digit:]]$")
strextr(s, "^[AB][[:digit:]]$", mult = TRUE)
strextr(s, "^[AB][[:digit:]]$", mult = TRUE, unlist = TRUE)
strextr(s, "^[C][[:digit:]]$")

#


Search within the miscset package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.