comparison core/tools/substrcellfind.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function [idx, strpos] = substrcellfind(strdb, str, findAll)
2 % [idx, strpos] = substrcellfind(strdb, str)
3 %
4 % finds a string within an cell array of strings
5 % only outputs the first occurence, unless
6 % findAll is set to true
7 %
8 % substrcellfind is NOT CASE sensitive
9
10 if nargin < 3
11 findAll = 0;
12 end
13
14 idx = [];
15 strpos = [];
16 for i = 1:length(strdb)
17
18 % search string in cell db
19 tpos = strfind(lower(char(strdb{i})), lower(str));
20
21 if ~isempty(tpos)
22
23 strpos(end+1) = tpos;
24
25 if ~findAll
26
27 idx = i;
28 return;
29 else
30 idx(end+1) = i;
31 end
32 end
33 end
34
35 % if isempty(idx)
36 % idx = -1;
37 % end