[R] how to implement string pattern extraction in R
Waverley @ Palo Alto
waverley.paloalto at gmail.com
Mon Aug 23 00:51:07 CEST 2010
Thanks for the reply to pointing me to the grep functions.
I have checked the readme page
http://pbil.univ-lyon1.fr/library/base/html/grep.html before I sent
the help request.
Just don't know how to extract a substring matching a pattern out of a
string. Can someone give me the example code similar to that in perl
to extract the prefix out of the string.
Thanks much.
On Sun, Aug 22, 2010 at 3:05 PM, Waverley @ Palo Alto
<waverley.paloalto at gmail.com> wrote:
> 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
>
--
Waverley @ Palo Alto
More information about the R-help
mailing list