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).
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.