grepex | R Documentation |
Given a character vector extract portions of each element with regular expressions.
grepex(pattern, x, multiple = FALSE, ...)
pattern |
character vector, regular expressions |
x |
character vector, strings from which to extract |
multiple |
logical, currently ignored |
... |
other arguments passed to |
Every element of x
is searched with patterns in pattern
using
regexpr
. The matches are then extracted.
A matrix r
, say, with length(pattern)
columns and
length(x)
rows. The entry r[i,j]
of this matrix is a portion
of x[i]
which is first match of pattern[i]
.
regexpr
x <- c("On 2010-02-01 John Smith had a beer",
"On 2010-02-02 Adam Smith did not have a beer",
"On 2010-02-03 Bob Smith had a beer again")
re <- c( isodate="\\<[0-9]{4}-[0-9]{2}-[0-9]{2}\\>",
name="\\<[A-Z][a-z]+\\> \\<[A-Z][a-z]+\\>",
beer="\\<beer\\>")
grepex(re, x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.