This appears to be a general R question, not Mac-specific, so would best be addressed on the general r-h...@r-project.org
> -----Original Message----- > From: r-sig-mac-boun...@stat.math.ethz.ch [mailto:r-sig-mac- > boun...@stat.math.ethz.ch] On Behalf Of orzack > Sent: Monday, June 22, 2009 12:15 PM > To: r-sig-mac@stat.math.ethz.ch > Subject: [R-SIG-Mac] negation in grep > > Does anybody know how to negate a string in a grep command, i.e., what > I need is to return only strings that do NOT contain a second string > anywhere in the entire string. > > > for > > txt <- c("boo","goo","doob","foo","boofoo") > > I need a grep command that returns strings with "oo" except when "b" > is present anywhere. The following yields all strings with "oo" except when "b" is present anywhere: R> txt[setdiff(grep("oo", txt), grep("b", txt))] [1] "goo" "foo" > I know that > > grep("[^b]oo" would work to exclude "boo" and "boofoo" but not "doob" > > So, what I need is > > grep("oo + some syntax", txt) > > should return > > goo doo foo I don't see "doo" in the example string vector "txt". Perhaps there is more to this that I didn't get? > > I have tried > > grep("oo!boo",txt) > > but it returns character(0). > any suggestions are much appreciated! > > S. > -- > Steven Orzack > > [[alternative HTML version deleted]] > > _______________________________________________ > R-SIG-Mac mailing list > R-SIG-Mac@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-mac HTH Steven McKinney _______________________________________________ R-SIG-Mac mailing list R-SIG-Mac@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-mac