1## Copyright (C) 1996, 1999, 2000, 2002, 2004, 2005, 2006, 2007, 2008, 2009
4## This file is part of Octave.
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
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
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.
16## You should have received a copy of the GNU General Public License
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
21## @deftypefn {Function File} {} rindex (@var{s}, @var{t})
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
28## rindex ("Teststring", "t")
33## @strong{Caution:} This function does not work for arrays of
35## @seealso{find, index}
38## Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at>
41function n = rindex (s, t)
43 ## This is patterned after the AWK function of the same name.
49 n = index (s, t, "last");
53%!assert(rindex ("foobarbaz", "b") == 7 && rindex ("foobarbaz", "o") == 3);
57%!error rindex ("foo", "bar", 3);