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

Last change on this file since 863 was 820, checked in by sommeria, 10 years ago

xmltree_updated

File size: 1.5 KB
Line 
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-2008  http://www.artefact.tk/
24
25% Guillaume Flandin <guillaume@artefact.tk>
26% $Id: xml_findstr.m 2271 2008-09-30 21:19:47Z 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.