Re: [R] partial matching with grep()

2009-11-09 Thread Adaikalavan Ramasamy
Try grep( "\\.x$", c("a.x" ,"b.x","a.xx"),value=TRUE) The $ means end-of-line (while ^ means start-of-line). And special characters like dot needs to be escaped twice. Regards, Adai Vito Muggeo (UniPa) wrote: dear all, This is a probably a silly question. If I type > grep("x",c("a.x"

Re: [R] partial matching with grep()

2009-11-02 Thread jim holtman
Is this what you want: depends on it occurring at the endo of the string: > grep("\\.x[^x]*$",c("a.x" ,"b.x","a.xx"),value=TRUE) [1] "a.x" "b.x" On Mon, Nov 2, 2009 at 9:57 AM, Vito Muggeo (UniPa) wrote: > dear all, > This is a probably a silly question. > If I type >> grep("x",c("a.x" ,"b.x",

Re: [R] partial matching with grep()

2009-11-02 Thread David Winsemius
On Nov 2, 2009, at 9:57 AM, Vito Muggeo (UniPa) wrote: dear all, This is a probably a silly question. If I type > grep("x",c("a.x" ,"b.x","a.xx"),value=TRUE) [1] "a.x" "b.x" "a.xx" > grep("\\.x\\b",c("a.x" ,"b.x","a.xx"),value=TRUE) [1] "a.x" "b.x" Or: > grep("\\.x$",c("a.x" ,"b.x","a.xx")

[R] partial matching with grep()

2009-11-02 Thread Vito Muggeo (UniPa)
dear all, This is a probably a silly question. If I type > grep("x",c("a.x" ,"b.x","a.xx"),value=TRUE) [1] "a.x" "b.x" "a.xx" Instead, I would like to obtain only "a.x" "b.x" How is it possible to get this result with grep()? many thanks for your attention, best, vito --