Say I have this Matlab or Octave char variable:
>> filename = 'my.file.ext'
I want a regexprep command that adds a suffix, say '_old', to the file name before the extension, transforming it into 'my.file_old.ext'.
The following replaces all dots with '_old.':
>> regexprep(filename, '\.', '_old.')
ans =
'my_old.file_old.ext'
What is a regexprep command that prepends '_old' only to the last dot? (Ideally, if there is no dot (no extension), append '_old' at the very end.)
Thank you in advance!