I have a function that sorts files based on file name. Two of the categories are 'Z7PR' and 'Z7PR1', which are two different tests. However, my sorting program sorts 'Z7PR' into 'Z7PR1', because it seems to match the 'Z7PR'. Is there anyway to distinguish the two without using 'Z7PR_' as I am currently doing?
Here is my code:
function otpS = filesort(inpS)
C = {'Z1P','Z2P','Z1G','Z2G','Z3K','Z4K','Z5K','Z3M','Z4M','Z5M','Z6MS','Z7PR_','Z7PR1'};
N = {inpS.name};
otpS = struct();
for k = 1:numel(C)
idx = cellfun('isempty',regexp(N,C{k},'once'));
otpS.(C{k}) = N(~idx);
end
end
2 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/346638-how-to-distinguish-two-similar-but-different-strings#comment_465090
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/346638-how-to-distinguish-two-similar-but-different-strings#comment_465090
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/346638-how-to-distinguish-two-similar-but-different-strings#comment_465093
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/346638-how-to-distinguish-two-similar-but-different-strings#comment_465093
サインインしてコメントする。