arnima at hafro.is
2009-Nov-09 15:35 UTC
[Rd] Alphanumeric tools::file_path_sans_ext() (PR#14050)
The file_path_sans_ext() function in the 'tools' package does not handle
alphanumeric file extensions correctly:
require(tools)
file_path_sans_ext("song.txt") # song, correct
file_path_sans_ext("song.mp3") # song.mp3, wrong
The help page states that "only purely alphanumeric extensions are
recognized", which I had expected. To fulfill this, the function body
should be
sub("([^.]+)\\.[[:alnum:]]+$", "\\1", x)
instead of the current definition:
sub("([^.]+)\\.[[:alpha:]]+$", "\\1", x)
Thanks,
Arni
Kurt Hornik
2009-Nov-10 20:03 UTC
[Rd] Alphanumeric tools::file_path_sans_ext() (PR#14050)
>>>>> arnima writes:> The file_path_sans_ext() function in the 'tools' package does not handle > alphanumeric file extensions correctly:> require(tools) > file_path_sans_ext("song.txt") # song, correct > file_path_sans_ext("song.mp3") # song.mp3, wrong> The help page states that "only purely alphanumeric extensions are > recognized", which I had expected. To fulfill this, the function body > should be> sub("([^.]+)\\.[[:alnum:]]+$", "\\1", x)> instead of the current definition:> sub("([^.]+)\\.[[:alpha:]]+$", "\\1", x)> Thanks,> ArniThanks, fixed now. Best -k> ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel