Skip to content
Prev 167429 / 398502 Next

regex -> negate a word

Wacek Kusnierczyk wrote:
incidentally, recent pcre accepts such regexes:

# r code
ungrep = function(pattern, x, ...)
    grep(paste(pattern, "(*COMMIT)(*FAIL)|(*ACCEPT)", sep=""), x,
perl=TRUE, ...)

strings = c("abc", "xyz")
pattern = "a[a-z]"
(filtered = strings[ungrep(pattern, strings)])
# "xyz"

vQ