Re: [R] perl expression question

2008-09-22 Thread jim holtman
If this is a path name, then 'basename' will work for you: > stock<-"/opt/limsrv/mark/research/equity/projects/testDL/stock_data/fhdb/US/BLC.NYSE" > basename(stock) [1] "BLC.NYSE" > On Mon, Sep 22, 2008 at 8:29 PM, <[EMAIL PROTECTED]> wrote: > If I have the string below. does someone know a reg

Re: [R] perl expression question

2008-09-22 Thread Gabor Grothendieck
By the way, although a regular expression solutions was asked for if one expands that to any solution then R does have a function specifically for this case: > basename(stock) [1] "BLC.NYSE" On Mon, Sep 22, 2008 at 9:23 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > >> sub(".*/",

Re: [R] perl expression question

2008-09-22 Thread Gabor Grothendieck
Try this: > sub(".*/", "", stock) [1] "BLC.NYSE" On Mon, Sep 22, 2008 at 8:29 PM, <[EMAIL PROTECTED]> wrote: > If I have the string below. does someone know a regular expression to just > get the "BLC.NYSE". I bought the O'Reilley > book and read it when I can and I study the solutions on the l

Re: [R] perl expression question

2008-09-22 Thread Andrew Robinson
Hi Mark, do you mean the regex to get the portion of the address after the final slash? Something like gsub(".*/([^/]*$)", "\\1", stock, fixed=FALSE) Cheers Andrew On Mon, Sep 22, 2008 at 07:29:25PM -0500, [EMAIL PROTECTED] wrote: > If I have the string below. does someone know a regular expr

Re: [R] perl expression question

2008-09-22 Thread Moshe Olshansky
Hi Mark, stock<-"/opt/limsrv/mark/research/equity/projects/testDL/stock_data/fhdb/US/BLC.NYSE" > gsub(".*/([^/]+)$", "\\1",stock) [1] "BLC.NYSE" --- On Tue, 23/9/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > From: [EMAIL PROTEC

[R] perl expression question

2008-09-22 Thread markleeds
If I have the string below. does someone know a regular expression to just get the "BLC.NYSE". I bought the O'Reilley book and read it when I can and I study the solutions on the list but I'm still not self sufficient with these things. Thanks. stock<-"/opt/limsrv/mark/research/equity/project

Re: [R] perl expression question

2008-08-12 Thread Gabor Grothendieck
It can be done like this with strapply in gsubfn. See home page at http://gsubfn.googlecode.com . strapply is like apply except the string to be operated on replaces the matrix and the regexp replaces the margin number and the function can be omitted if you are only returning one item.Its like

Re: [R] perl expression question

2008-08-12 Thread jim holtman
Will this do it: > fileName<-"Agg.20.20.20-all-01" > sub(".*\\.(\\d+\\.\\d+\\.\\d+).*", "\\1", fileName, perl=TRUE) [1] "20.20.20" > sub(".*-([^-]+)-.*", "\\1", fileName, perl=TRUE) [1] "all" > On Tue, Aug 12, 2008 at 4:18 PM, <[EMAIL PROTECTED]> wrote: > I have a string such as > > fileName<-"

[R] perl expression question

2008-08-12 Thread markleeds
I have a string such as fileName<-"Agg.20.20.20-all-01". All I want to do is pull the "20.20.20" and the "all" as strings. Obviously, they aren't always those values. The "20.20.20" can be "30.30.30" but it's always after the . which is next to the second g in Agg and it's always the same len