[R] Retrieve regular expression groups
Gabor Grothendieck
ggrothendieck at gmail.com
Mon May 3 01:02:25 CEST 2010
The strapply function in gsubfn does that. See http://gsubfn.googlecode.com
On Sun, May 2, 2010 at 6:03 PM, OKB (not okblacke)
<brenbarn at brenbarn.net> wrote:
> I'm trying to figure out how to get the text captured by capturing
> groups out of a regex match. For instance, let's say I have the pattern
> "foo ([^ ]+)" and I match it against the string "This is a foo sentence
> I am reading." The group in the pattern will match the word "sentence"
> in the target string. How can I get access to this matched group? All
> I can seem to get the various grep/gsub functions to do is return or
> modify the entire target string. Isn't there a way to extract ONLY the
> text from a particular group or groups?
>
> Thanks,
> --
> --OKB (not okblacke)
> Brendan Barnwell
> "Do not follow where the path may lead. Go, instead, where there is
> no path, and leave a trail."
> --author unknown
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list