strextract: Extract matched substrings by regular expression.

Description Usage Arguments Value Author(s) Examples

View source: R/strextract.R

Description

Extract matched substrings by regular expression.

Usage

1
2
strextract(string, pattern, invert = FALSE, ignore.case = FALSE,
  perl = FALSE, useBytes = FALSE)

Arguments

string

A character vector.

pattern

A character string containing a regular expression to be matched in the given character vector.

invert

A logical value: if TRUE, extract the non-matched substrings.

ignore.case

If FALSE, the pattern matching is case sensitive and if TRUE, case is ignored during matching.

perl

A logical value. Should perl-compatible regexps be used?

useBytes

A logical value. If TRUE the matching is done byte-by-byte rather than character-by-character.

Value

A character vector with the matched or non-matched substrings.

Author(s)

Jian Li <rweibo@sina.com>

Examples

1
2
3
4
txt1 <- c("\t(x1)a(aa2)a ", " bb(bb)")
strextract(txt1, "\\([^)]*\\)")
txt2 <- c("  Ben Franklin and Jefferson Davis", "\tMillard Fillmore")
strextract(txt2, "(?<first>[[:upper:]][[:lower:]]+)", perl = TRUE)

tmcn documentation built on Aug. 4, 2019, 3 p.m.

Related to strextract in tmcn...