ngrep: Anti-grep

Description Usage Arguments Value Examples

View source: R/ngrep.R

Description

It is not simple to negate a regular expression. This obviates the need takes the long way round: negating the corresponding grepl call.

Usage

1
ngrep(pattern, x, value = FALSE, ...)

Arguments

x, value, pattern

As in grep.

...

Arguments passed to grepl.

Value

If value is FALSE (the default), indices of x which do not match the pattern; if TRUE, the values of x themselves.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 grep("[a-h]", letters)
ngrep("[a-h]", letters)

txt <- c("The", "licenses", "for", "most", "software", "are",
"designed", "to", "take", "away", "your", "freedom",
"to", "share", "and", "change", "it.",
"", "By", "contrast,", "the", "GNU", "General", "Public", "License",
"is", "intended", "to", "guarantee", "your", "freedom", "to",
"share", "and", "change", "free", "software", "--",
"to", "make", "sure", "the", "software", "is",
"free", "for", "all", "its", "users")

 grep("[gu]", txt, value = TRUE)
ngrep("[gu]", txt, value = TRUE)

hutils documentation built on Nov. 1, 2018, 5:05 p.m.