Count regex matches within each element of a character vector
Arguments
- pattern
pattern to search for, passed to
gregexec()- x
a vector of character strings to search within
- ignore.case
passed to
gregexec()
Examples
grepn("x", c("0 abc", "1 uppercase X", "1 xyz", "2 xx", "3 x x x"))
grepn("x", c("0 abc", "1 uppercase X", "1 xyz", "2 xx", "3 x x x"), ignore.case = FALSE)
grepns(c("x", "y"), c("yes", "yx", "this 1 has some x x xxxxx"))
grepns(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = TRUE, count1perx = TRUE)
grepns(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = FALSE, count1perx = TRUE)
grepns(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = TRUE, count1perx = FALSE)
grepns(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = FALSE, count1perx = FALSE)
grepls(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = TRUE)
grepls(c("hi", "other", 'x'), c("said hi ther hi hi hi e", 'hi', 'another', 'none'),
rowperx = FALSE)