[R] question of R to do perl matching and matched string extraction

jim holtman jholtman at gmail.com
Thu Oct 9 04:02:33 CEST 2008


Is this what you want:

> x <- "/pages-cell.net/deepan/sony/"
> z <- gsub("/(.*)/", "\\1", x)
>
> z
[1] "pages-cell.net/deepan/sony"



On Wed, Oct 8, 2008 at 8:20 PM, Waverley <waverley.paloalto at gmail.com> wrote:
> Hi,
>
> I want to extract some of the substring via pattern recognition.  But
> I don't know how to do it in R.
>
> In perl:
> my $url = "/pages-cell.net/deepan/sony/";
>
> if($url =~ m/\/(.*)\//g)
> {
> my @result = $1;
> return @result;
> }
>
>
> How does the same work in R?
>
> Thanks much in advance
> --
> Waverley @ Palo Alto
>
> ______________________________________________
> 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
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list