[R] grep for strings
jim holtman
jholtman at gmail.com
Sun Dec 5 04:32:53 CET 2010
> 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?
More information about the R-help
mailing list