On Fri, Jan 9, 2009 at 4:20 PM, Wacek Kusnierczyk
<waclaw.marcin.kusnierc...@idi.ntnu.no> wrote:
>
>> Duncan Murdoch wrote:
>>
>>>
>>> I'm curious about something: does "file extension" have a standard
>>> definition?  Most (all?  I haven't tried them all) of the solutions
>>> presented in this thread would return an empty string for the "plain
>>> base" if given the filename ".bashrc".
>>>
>
>
> right;  there's a straightforward fix to my solution that accounts for
> cases such as '.bashrc':
>
> names = c("foo.bar", ".zee")
> sub("(.+)[.][^.]+$", "\\1", names)
>
> you could also use a lookbehind if possible (not in r, afaik).
>

or:

> sub(".*[.]", ".", names)
[1] ".bar" ".zee"

______________________________________________
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