I want to get the path to the file name in MATLAB, for example dirname, and basenameon Linux. I tried to find a function like strrchr, but I failed. I know that strtok, strfindand textscancan be used, but I want to accomplish this with no more than two operators.
dirname
basename
strrchr
strtok
strfind
textscan
For this specific problem, I suggest you use the function : fileparts
fileparts
[path, filename, extension] = fileparts(str)
The answer to Nick definitely does what you ask for, but here is an alternative answer using regexprep:
regexprep
regexprep(str, '(.+)(?:\\|/)(.*)', '$1')
( ), $2 $1. , MATLAB .
$2
$1