Skip to content
Prev 74815 / 398502 Next

regexpr and portability issue

Try this.  The regular expression says to match 
- anything 
- followed by a double underscore 
- followed by one or more digits
- followed by an underscore 
- followed by anything.  
The digits have been parenthesized so that they can be referred to in
the backreference "\\1".    Also use the R function dirname
rather than regular expressions.

base.name <- sub(".*__([[:digit:]]+)_.*", "\\1", aFileName, ext = TRUE)
base.dir <- dirname(aFileName)
On 8/3/05, Marco Blanchette <mblanche at uclink.berkeley.edu> wrote: