[R] gregexpr() - length of the matched text to a vector

Petri Palmu petri.palmu at geneos.fi
Wed Jan 11 15:38:08 CET 2006


Now I found a solution that seems to work OK for me:
attributes(gregexpr(expression, text)[[1]])

Petri

At 15:00 11.1.2006 +0100, Petri Palmu wrote:


>Hi,
>
>I'm using gregexpr(). As a result something like this:
>
># starting positions of the match:
>[[1]]
>[1] 7 18
>
># length of the matched text:
>attr(,"match.length")
>[1] 4 4
>
>Now, I'd like to have a matrix,
>   7    4
>18   4
>
>but I don't know how to handle the attr(,"match.length") ...?
>The format of the output is pretty unclear to me in that respect.
>
>Thanks in advance,
>Petri
>----------------------
>Petri Palmu, M.Soc.Sc
>Statistician
>petri.palmu at geneos.fi
>
>Geneos Ltd
>tel:+358 9 4366 2512
>gsm: +35840 55 249 55
>fax:+ 358 9 4366 2523
>P.O. Box 25 (Tukholmankatu 2)
>FIN-00251, Helsinki, Finland
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


----------------------
Petri Palmu, M.Soc.Sc
Statistician
petri.palmu at geneos.fi

Geneos Ltd
tel:+358 9 4366 2512
gsm: +35840 55 249 55
fax:+ 358 9 4366 2523
P.O. Box 25 (Tukholmankatu 2)
FIN-00251, Helsinki, Finland




More information about the R-help mailing list