Message-ID: <AANLkTikOznFry2ErJmzD5CVvSVPxe6Oa4OdKE6K9dF6N@mail.gmail.com>
Date: 2010-12-05T03:32:53Z
From: jim holtman
Subject: grep for strings
In-Reply-To: <AANLkTinYPp2OfGuKUHxsxV_PJv+urnKZjbm9edBTf6CE@mail.gmail.com>
> 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
<santosh.srinivas at gmail.com> 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 "cd" and
> in case there are multiple hits .. then the results as a array
>
> Thank you.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?