[R] how to implement string pattern extraction in R

Waverley @ Palo Alto waverley.paloalto at gmail.com
Mon Aug 23 00:05:07 CEST 2010


Hi,

In perl, to get a substring matching a particular  pattern can be
implemented like the following example:

$x = "AAAA.txt";
if ($x=~ /(.*?)\.txt/){
  $prefix = $1;
}

So how to do the same thing in R?

Can someone provide me the code sample?

Thanks much in advance.

-- 
Waverley @ Palo Alto



More information about the R-help mailing list