Wacek Kusnierczyk wrote: > > # 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" >
this was a toy example, but if you need this sort of ungrep with patterns involving alterations, you need a fix: ungrep("a|x", strings, value=TRUE) # "abc" # NOT character(0) # fix ungrep = function(pattern, x, ...) grep(paste("(?:", pattern, ")(*COMMIT)(*FAIL)|(*ACCEPT)", sep=""), x, perl=TRUE, ...) ungrep("a|x", strings, value=TRUE) # character(0) vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.