Re: [R] R regular expression to extract words with the query string.

2009-07-08 Thread Gabor Grothendieck
The solution below does not include the pid: string before it. This modification works: > strapply(i, paste("[^ ]*", "ENSP", "[^ ]*", sep = ""), c, simplify = unlist) [1] "pid:ENSP12345" On Wed, Jul 8, 2009 at 10:08 AM, Gabor Grothendieck wrote: > Try this: > > library(gsubfn) > i <- "transcr

Re: [R] R regular expression to extract words with the query string.

2009-07-08 Thread Gabor Grothendieck
Try this: library(gsubfn) i <- "transcript:ENST112334 pid:ENSP12345" strapply(i, paste("\\w*", "ENSP", "\\w*", sep = ""), c, simplify = unlist) This says to match any number (possibly zero) of word characters followed by ENSP followed by more word characters. c just returns the match wit

Re: [R] R regular expression to extract words with the query string.

2009-07-08 Thread Jorge Ivan Velez
Dear Praveen, Try also: strsplit(i,' ')[[1]][2] # [1] "pid:ENSP12345" HTH, Jorge On Wed, Jul 8, 2009 at 9:04 AM, Praveen Surendran wrote: > Hi, > > > > Is there a way in R to get the string which matches the expression, where > the expression is a substring of the parent string. > > > > L

[R] R regular expression to extract words with the query string.

2009-07-08 Thread Praveen Surendran
] Sent: 08 July 2009 14:18 To: praveen.surend...@ucd.ie Cc: r-help@r-project.org Subject: Re: [R] R regular expression to extract words with the query string. Try this: sapply(strsplit(i, ' '), grep, pattern='ENSP', value = T) On Wed, Jul 8, 2009 at 10:04 AM, Praveen Surend

Re: [R] R regular expression to extract words with the query string.

2009-07-08 Thread Henrique Dallazuanna
Try this: sapply(strsplit(i, ' '), grep, pattern='ENSP', value = T) On Wed, Jul 8, 2009 at 10:04 AM, Praveen Surendran wrote: > Hi, > > > > Is there a way in R to get the string which matches the expression, where > the expression is a substring of the parent string. > > > > Lets say, I have $i

[R] R regular expression to extract words with the query string.

2009-07-08 Thread Praveen Surendran
Hi, Is there a way in R to get the string which matches the expression, where the expression is a substring of the parent string. Lets say, I have $i <- "transcript:ENST112334 pid:ENSP12345" What I need is the string "pid:ENSP12345" from $i using the query "ENSP". Appreciat