Mercurial > octave-nkf
annotate scripts/strings/rindex.m @ 9051:1bf0ce0930be
Grammar check TexInfo in all .m files
Cleanup documentation sources to follow a few consistent rules.
Spellcheck was NOT done. (but will be in another changeset)
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Fri, 27 Mar 2009 22:31:03 -0700 |
parents | eb63fbe60fab |
children | 16f53d29049f |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1996, 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008 |
7017 | 2 ## Kurt Hornik |
2325 | 3 ## |
2313 | 4 ## This file is part of Octave. |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
2271 | 19 |
3361 | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} rindex (@var{s}, @var{t}) | |
6139 | 22 ## Return the position of the last occurrence of the character string |
23 ## @var{t} in the character string @var{s}, or 0 if no occurrence is | |
24 ## found. For example, | |
3426 | 25 ## |
3361 | 26 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
27 ## @group |
3361 | 28 ## rindex ("Teststring", "t") |
29 ## @result{} 6 | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
30 ## @end group |
3361 | 31 ## @end example |
3426 | 32 ## |
6139 | 33 ## @strong{Caution:} This function does not work for arrays of |
34 ## character strings. | |
35 ## @seealso{find, index} | |
3361 | 36 ## @end deftypefn |
2271 | 37 |
5428 | 38 ## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> |
2355 | 39 ## Adapted-By: jwe |
2314 | 40 |
2311 | 41 function n = rindex (s, t) |
2271 | 42 |
2303 | 43 ## This is patterned after the AWK function of the same name. |
2271 | 44 |
45 if (nargin != 2) | |
6046 | 46 print_usage (); |
2271 | 47 endif |
48 | |
6139 | 49 n = index (s, t, "last"); |
3911 | 50 |
2271 | 51 endfunction |
7411 | 52 |
53 %!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3); | |
54 | |
55 %!error rindex (); | |
56 | |
57 %!error rindex ("foo", "bar", 3); | |
58 |