第1个回答 2010-04-09
>> help strfind
STRFIND Find one string within another.
K = STRFIND(TEXT,PATTERN) returns the starting indices of any
occurrences of the string PATTERN in the string TEXT.
STRFIND will always return [] if PATTERN is longer than TEXT.
Examples
s = 'How much wood would a woodchuck chuck?';
strfind(s,'a') returns 21
strfind('a',s) returns []
strfind(s,'wood') returns [10 23]
strfind(s,'Wood') returns []
strfind(s,' ') returns [4 9 14 20 22 32]
See also strcmp, strncmp, regexp.
Overloaded methods:
cell/strfind
Reference page in Help browser
doc strfind
如果是针对文件名,这个或许也有帮助
>> help fileparts
FILEPARTS Filename parts.
[PATHSTR,NAME,EXT] = FILEPARTS(FILE) returns the path,
filename and extension for the specified file.
FILEPARTS is platform dependent.
You can reconstruct the file from the parts using
fullfile(pathstr,[name ext versn])
The fourth output, VERSN, of FILEPARTS will be removed in a future
release.
See also fullfile, pathsep, filesep.
Reference page in Help browser
doc fileparts