Description Usage Arguments Value Author(s) Examples
Extract matched substrings by regular expression.
1 2 |
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. |
A character vector with the matched or non-matched substrings.
Jian Li <rweibo@sina.com>
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.