Re: [R] Perl-style regexes and capturing results

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 05 May 2006 - 00:00:27 EST

On Thu, 4 May 2006, Sean Davis wrote:

> Just a quick question....
>
> In perl, I can capture parts of a regex like /(\w)\/(\d)/ to get back $1 and
> $2 containing the parts of the regex in parentheses. Is there a parallel in
> R?

Yes. See ?gsub and especially the examples. This is not specific to Perl, and \1 and \2 are more commonly used, including in R.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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
Received on Fri May 05 00:17:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 05 May 2006 - 02:09:59 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.