Re: [R] grep for strings

2010-12-05 Thread sayan dasgupta
Hi Santosh, you may also try require(stringr) x <- "abcdefghijklcd" str_locate_all(x,"cd") On Sun, Dec 5, 2010 at 1:21 PM, Petr Savicky wrote: > On Sun, Dec 05, 2010 at 08:04:08AM +0530, Santosh Srinivas wrote: > > I am trying to find the function where I can search for a pattern in a > > te

Re: [R] grep for strings

2010-12-04 Thread Petr Savicky
On Sun, Dec 05, 2010 at 08:04:08AM +0530, Santosh Srinivas wrote: > I am trying to find the function where I can search for a pattern in a > text string (I thought I could use grep for this but no :(). > > > x > [1] "abcdefghijkl" > > I want to find the positions (i.e. equivalent of nchar) for "c

Re: [R] grep for strings

2010-12-04 Thread jim holtman
> x <- "abcdefghijkl" > ?regexpr starting httpd help server ... done > regexpr('cd', x) [1] 3 attr(,"match.length") [1] 2 > On Sat, Dec 4, 2010 at 9:34 PM, Santosh Srinivas wrote: > I am trying to find the function where I can search for a pattern in a > text string (I thought I could use grep f

Re: [R] grep for strings

2010-12-04 Thread Charles C. Berry
On Sun, 5 Dec 2010, Santosh Srinivas wrote: I am trying to find the function where I can search for a pattern in a text string (I thought I could use grep for this but no :(). Correct, but reading ?grep and running example( grep ) should show you how to do that search.

[R] grep for strings

2010-12-04 Thread Santosh Srinivas
I am trying to find the function where I can search for a pattern in a text string (I thought I could use grep for this but no :(). > x [1] "abcdefghijkl" I want to find the positions (i.e. equivalent of nchar) for "cd" and in case there are multiple hits .. then the results as a array Thank you