grep2 {JATSdecoder} | R Documentation |
grep2
Description
Extension of grep(). Allows to identify and extract cells with/without multiple search patterns that are connected with AND.
Usage
grep2(pattern, x, value = TRUE, invert = FALSE, perl = FALSE)
Arguments
pattern |
Character vector containing regular expression as cells to be matched in the given character vector. |
x |
A character vector where matches are sought, or an object which can be coerced by as.character to a character vector. Long vectors are supported. |
value |
Logical. If FALSE, a vector containing the (integer) indices of the matches determined by grep2 is returned, and if TRUE, a vector containing the matching elements themselves is returned. |
invert |
Logical. If TRUE return indices or values for elements that do not match. |
perl |
Logical. Should Perl-compatible regexps be used? |
Value
grep2(value = FALSE) returns a vector of the indices of the elements of x that yielded a match (or not, for invert = TRUE). This will be an integer vector unless the input is a long vector, when it will be a double vector.
grep2(value = TRUE) returns a character vector containing the selected elements of x (after coercion, preserving names but no other attributes).
See Also
Examples
x<-c("ab","ac","ad","bc","bad")
grep2(c("a","b"),x)
grep2(c("a","b"),x,invert=TRUE)
grep2(c("a","b"),x,value=FALSE)