We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d0d04c8 commit 6cacd51Copy full SHA for 6cacd51
+stdlib/root_dir.m
@@ -13,19 +13,22 @@
13
p {mustBeTextScalar}
14
end
15
16
-r = '';
17
-pc = char(p);
18
-
19
-if startsWith(p, {'/', filesep})
20
- r = pc(1);
21
-elseif strlength(p) > 2 && ~strempty(stdlib.root_name(p))
22
- if ismember(pc(3), {'/', filesep})
23
- r = pc(3);
+matches = regexp(p, '^([/\\])|^[A-Za-z]:([/\\])', 'tokens');
+
+if isempty(matches)
+ r = '';
+ if isstring(p)
+ r = "";
+ end
24
25
+else
26
27
+ r = matches{1};
28
+ if iscell(r)
29
+ r = r{1};
30
-end
31
-if isstring(p)
- r = string(r);
32
33
34
0 commit comments