grep {base} | R Documentation |
grep
searches for matches to pattern given as its first
argument within the the vector of character strings given as
its second argument.
sub
and gsub
perform replacement of matches
determined by regular expression matching.
The functions differ only in that sub
replaces only
the first occurence of a pattern whereas gsub
replaces
all occurences.
The regular expressions used are those specified by POSIX 1003.2,
either extended or basic, depending on the value of the
extended
argument.
grep(pattern, x, ignore.case=FALSE, extended=TRUE, value=FALSE)
sub(pattern, replacement, x,
ignore.case=FALSE, extended=TRUE)
gsub(pattern, replacement, x,
ignore.case=FALSE, extended=TRUE)
pattern |
character string containing a regular expression
to be matched in the vector of character string |
x |
a vector of character strings where matches is sought. |
ignore.case |
if |
extended |
if |
value |
if |
replacement |
a replacement for matched pattern in
|
This function is based on the regex regular expression library written by Henry Spencer of the University of Toronto.
match
, pmatch
.
grep("[a-z]", letters)