comparison scripts/strings/findstr.m @ 8442:502e58a0d44f

Fix docstrings, add examples, references and tests to string functions
author Thorsten Meyer <thorsten.meyier@gmx.de>
date Mon, 05 Jan 2009 08:11:03 +0100
parents 83a8781b529d
children bc982528de11
comparison
equal deleted inserted replaced
8441:cc3ac5eb6be3 8442:502e58a0d44f
23 ## @var{s} and @var{t} where an occurrence of the shorter of the two starts. 23 ## @var{s} and @var{t} where an occurrence of the shorter of the two starts.
24 ## If the optional argument @var{overlap} is nonzero, the returned vector 24 ## If the optional argument @var{overlap} is nonzero, the returned vector
25 ## can include overlapping positions (this is the default). For example, 25 ## can include overlapping positions (this is the default). For example,
26 ## 26 ##
27 ## @example 27 ## @example
28 ## @group
28 ## findstr ("ababab", "a") 29 ## findstr ("ababab", "a")
29 ## @result{} [ 1, 3, 5 ] 30 ## @result{} [1, 3, 5]
30 ## findstr ("abababa", "aba", 0) 31 ## findstr ("abababa", "aba", 0)
31 ## @result{} [ 1, 5 ] 32 ## @result{} [1, 5]
33 ## @end group
32 ## @end example 34 ## @end example
35 ## @seealso{strfind, strmatch, strcmp, strncmp, strcmpi, strncmpi, find}
33 ## @end deftypefn 36 ## @end deftypefn
34 37
35 ## Note that this implementation swaps the strings if second one is longer 38 ## Note that this implementation swaps the strings if second one is longer
36 ## than the first, so try to put the longer one first. 39 ## than the first, so try to put the longer one first.
37 ## 40 ##
127 v = v.'; 130 v = v.';
128 endif 131 endif
129 132
130 endfunction 133 endfunction
131 134
132 %!assert((findstr ("abababa", "a") == [1, 3, 5, 7] 135 %!assert ((findstr ("abababa", "a") == [1, 3, 5, 7]
133 %! && findstr ("abababa", "aba") == [1, 3, 5] 136 %! && findstr ("abababa", "aba") == [1, 3, 5]
134 %! && findstr ("abababa", "aba", 0) == [1, 5])); 137 %! && findstr ("abababa", "aba", 0) == [1, 5]));
135 138
136 %!error findstr (); 139 %!error findstr ();
137 140