source: trunk/src/@xmltree/private/xml_findstr.m @ 1062

Last change on this file since 1062 was 925, checked in by sommeria, 9 years ago

xmltree updated

File size: 1.5 KB
RevLine 
[925]1function k = xml_findstr(s,p,i,n)
2%XML_FINDSTR Find one string within another
3%   K = XML_FINDSTR(TEXT,PATTERN) returns the starting indices of any
4%   occurrences of the string PATTERN in the string TEXT.
5%
6%   K = XML_FINDSTR(TEXT,PATTERN,INDICE) returns the starting indices
7%   equal or greater than INDICE of occurrences of the string PATTERN
8%   in the string TEXT. By default, INDICE equals to one.
9%
10%   K = XML_FINDSTR(TEXT,PATTERN,INDICE,NBOCCUR) returns the NBOCCUR
11%   starting indices equal or greater than INDICE of occurrences of
12%   the string PATTERN in the string TEXT. By default, INDICE equals
13%   to one and NBOCCUR equals to Inf.
14%
15%   Examples
16%       s = 'How much wood would a woodchuck chuck?';
17%       xml_findstr(s,' ') returns [4 9 14 20 22 32]
18%       xml_findstr(s,' ',10) returns [14 20 22 32]
19%       xml_findstr(s,' ',10,1) returns 14
20%
21%   See also STRFIND, FINDSTR
22%__________________________________________________________________________
23% Copyright (C) 2002-2011  http://www.artefact.tk/
24
25% Guillaume Flandin
26% $Id: xml_findstr.m 4460 2011-09-05 14:52:16Z guillaume $
27
28%error(sprintf('Missing MEX-file: %s', mfilename));
29
30persistent runonce
31if isempty(runonce)
32    warning(sprintf(['xml_findstr is not compiled for your platform.\n'...
33    'This will result in a slowdown of the XML parsing.']));
34    runonce = 1;
35end
36
37% k = regexp(s(i:end),p,'once') + i - 1;
38if nargin < 3, i = 1;   end
39if nargin < 4, n = Inf; end
40j = strfind(s,p);
41k = j(j>=i);
42if ~isempty(k), k = k(1:min(n,length(k))); end
Note: See TracBrowser for help on using the repository browser.