Re: [R] Escaping . in regular expression

2009-09-14 Thread Prof. John C Nash
Thanks. That fixes things. I saw mention of \\. in ?Quotes, but the usage was not clear. I took it to mean the \ was to be printed. Maybe my little example would help, as ?Quotes doesn't have any. JN Henrique Dallazuanna wrote: You need double backslashes: grep('\\.f', cvec, value = TRUE)

Re: [R] Escaping . in regular expression

2009-09-14 Thread Duncan Murdoch
On 9/14/2009 3:25 PM, Prof. John C Nash wrote: If I run cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") print(cvec) indx<-grep('\.f',cvec,perl=TRUE) fset<-cvec[indx] print(fset) I get > cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") > print(cvec) [1] "test.f" "test.sf" "

Re: [R] Escaping . in regular expression

2009-09-14 Thread Henrique Dallazuanna
You need double backslashes: grep('\\.f', cvec, value = TRUE) On Mon, Sep 14, 2009 at 4:25 PM, Prof. John C Nash wrote: > If I run > > > cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") > print(cvec) > indx<-grep('\.f',cvec,perl=TRUE) > fset<-cvec[indx] > print(fset) > > I get > > > cvec

[R] Escaping . in regular expression

2009-09-14 Thread Prof. John C Nash
If I run cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") print(cvec) indx<-grep('\.f',cvec,perl=TRUE) fset<-cvec[indx] print(fset) I get > cvec<-c("test.f", "test.sf", "try.g","try.res", "try.f") > print(cvec) [1] "test.f" "test.sf" "try.g" "try.res" "try.f" > indx<-grep("\.f",cvec