[925] | 1 | function 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 |
|
---|
| 30 | persistent runonce
|
---|
| 31 | if 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;
|
---|
| 35 | end
|
---|
| 36 |
|
---|
| 37 | % k = regexp(s(i:end),p,'once') + i - 1;
|
---|
| 38 | if nargin < 3, i = 1; end
|
---|
| 39 | if nargin < 4, n = Inf; end
|
---|
| 40 | j = strfind(s,p);
|
---|
| 41 | k = j(j>=i);
|
---|
| 42 | if ~isempty(k), k = k(1:min(n,length(k))); end
|
---|