> sub( "\\.[^.]*$", "", fname ) fwiw, i almost always use '[.]' in preference to '\\\\\\\\.', as it seems to be more likely to get through the various levels of quoting in different contexts.