unglue_detect {unglue} | R Documentation |
Detect if strings are matched by a set of unglue patterns
Description
Returns a logical indicating whether input strings were matched by one or more patterns
Usage
unglue_detect(
x,
patterns,
open = "{",
close = "}",
convert = FALSE,
multiple = NULL
)
Arguments
x |
a character vector to unglue. |
patterns |
a character vector or a list of character vectors, if a list,
items will be pasted using an empty separator ( |
open |
The opening delimiter. |
close |
The closing delimiter. |
convert |
If |
multiple |
The aggregation function to use if several subpatterns are
named the same, by default no function is used and subpatterns named the
same will match the same value. If a function is provided it will be fed
the conflicting values as separate arguments. Formula notation
is supported if the package |
Value
a vector of logical.
Examples
sentences <- c("666 is [a number]", "foo is [a word]",
"42 is [the answer]", "Area 51 is [unmatched]")
patterns <- c("{number=\\d+} is [{what}]", "{word=\\D+} is [{what}]")
unglue_detect(sentences, patterns)