File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change 11%% STEM base file name without directory or suffix
2- % STEM Extracts the file name without directory or suffix from a path.
32% s = stem(p) returns the stem (base name) of the file specified by the path p.
43% leading dot filenames are allowed.
54%
6- % Input :
7- % p - Character vector or string scalar specifying the file path.
5+ % %% Inputs :
6+ % * p: Character vector or string scalar specifying the file path.
87%
9- % Output:
10- % s - Character vector or string scalar containing the file name without directory or suffix.
11-
12- function s = stem(p )
8+ % %% Output:
9+ % * s: Character vector or string scalar containing the file name without directory or suffix.
10+ %
11+ % Note: fileparts() was about 100x faster then using multiple steps with pattern.
12+ function s = stem(filepath )
1313arguments
14- p string
14+ filepath string
1515end
1616
17- p0 = asManyOfPattern(wildcardPattern + (" /" | filesep ));
18- % p1 matches a file extension (e.g., '.txt') or the end of the string
19- p1 = (" ." + alphanumericsPattern + textBoundary(' end' )) | textBoundary(' end' );
20-
21- s = extractBetween(p , p0 , p1 );
17+ [~ , s , e ] = fileparts(filepath );
2218
2319i = stdlib .strempty(s );
24- s(i ) = extractAfter(p( i ), p0 );
20+ s(i ) = e( i );
2521
2622end
You can’t perform that action at this time.
0 commit comments