The S+ basename() function has an argument called suffix and
it will remove the suffix from the result.  This was based on
the Unix basename command, but I missed the special case in the
Unix basename that doesn't remove the suffix if the removal
would result in an empty string.  The suffix must include any
initial dot.  Unlike the Unix basename, the suffix is a regular
expression (but other regexpr arguments like ignore.case and
fixed are not acceptedi - there ought to be a regular expression
class so these things get attached to the expression instead of
added to the call). 
  
  > basename(c("foobar", "dir/foo.bar"), suffix=".bar")
  [1] "fo"  "foo"
  > basename(c("foobar", "dir/foo.bar"), suffix="\\.bar")
  [1] "foobar" "foo"   
 
Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

______________________________________________
R-help@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.

Reply via email to