How are regexpr, gregexpr and regexec different than grep/grepl?
grep()
, grepl()
:
These functions search for matches of a regular expression/pattern
in a character vector. grep()
returns the indices into
the character vector that contain a match or the specific strings
that happen to have the match. grepl()
returns a
TRUE
/FALSE
vector indicating which
elements of the character vector contain a match.
regexpr()
,
gregexpr()
: Search a character vector for regular
expression matches and return the indices of the string where the
match begins and the length of the match
regexec()
: This function searches
a character vector for a regular expression, much like
regexpr()
, but it will additionally return the
locations of any parenthesized sub-expressions.
please rate my answer and comment for doubts.
Get Answers For Free
Most questions answered within 1 hours.