-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added explicit starts/endsWith functions
- Loading branch information
Beliy Nikita
committed
Feb 22, 2021
1 parent
568e0cf
commit e68a18c
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function res = endsWith(str, pat) | ||
% | ||
% Checks id character array 'str' ends with 'pat' | ||
% | ||
% USAGE res = bids.internal.endsWith(str, pat) | ||
% | ||
% str - character array | ||
% pat - character array | ||
% | ||
% __________________________________________________________________________ | ||
% | ||
% Based on spm_file.m and spm_select.m from SPM12. | ||
% __________________________________________________________________________ | ||
|
||
% Copyright (C) 2011-2018 Guillaume Flandin, Wellcome Centre for Human Neuroimaging | ||
res = false; | ||
l_pat = length(pat); | ||
if l_pat > length(str) | ||
return; | ||
end | ||
res = strcmp(str(end - l_pat +1 : end), pat); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function res = startsWith(str, pat) | ||
% | ||
% Checks id character array 'str' starts with 'pat' | ||
% | ||
% USAGE res = bids.internal.startsWith(str, pat) | ||
% | ||
% str - character array | ||
% pat - character array | ||
% | ||
% __________________________________________________________________________ | ||
% | ||
% Based on spm_file.m and spm_select.m from SPM12. | ||
% __________________________________________________________________________ | ||
|
||
% Copyright (C) 2011-2018 Guillaume Flandin, Wellcome Centre for Human Neuroimaging | ||
res = false; | ||
l_pat = length(pat); | ||
if l_pat > length(str) | ||
return; | ||
end | ||
res = strcmp(str(1 : l_pat), pat); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters