Mercurial > hg > octave-lyh
annotate scripts/strings/strcmpi.m @ 9111:96e7a72be5e7
typo
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 12 Apr 2009 11:08:56 +0200 |
parents | 1bf0ce0930be |
children |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2000, 2005, 2006, 2007, 2009 Bill Lash |
5185 | 2 ## |
5186 | 3 ## This file is part of Octave. |
5185 | 4 ## |
5186 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5186 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
5185 | 14 ## |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5185 | 18 |
5186 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} strcmpi (@var{s1}, @var{s2}) | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
21 ## Ignoring case, return 1 if the character strings (or character |
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
22 ## arrays) @var{s1} and @var{s2} are the same, and 0 otherwise. |
5185 | 23 ## |
5674 | 24 ## If either @var{s1} or @var{s2} is a cell array of strings, then an array |
25 ## of the same size is returned, containing the values described above for | |
9036
58604c45ca74
Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
26 ## every member of the cell array. The other argument may also be a cell |
5674 | 27 ## array of strings (of the same size or with only one element), char matrix |
28 ## or character string. | |
29 ## | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9036
diff
changeset
|
30 ## @strong{Caution:} For compatibility with @sc{matlab}, Octave's strcmpi |
5674 | 31 ## function returns 1 if the character strings are equal, and 0 otherwise. |
32 ## This is just the opposite of the corresponding C library function. | |
33 ## @seealso{strcmp, strncmp, strncmpi} | |
5186 | 34 ## @end deftypefn |
5185 | 35 |
36 ## Author: Bill Lash <lash@tellabs.com> | |
5186 | 37 ## Adapted-by: jwe |
5185 | 38 |
5674 | 39 function retval = strcmpi (s1, s2) |
5185 | 40 |
5186 | 41 if (nargin == 2) |
5762 | 42 if ((ischar(s1) || iscellstr(s1)) && (ischar(s2) || iscellstr(s2))) |
43 ## Note that we don't use tolower here because we need to be able | |
44 ## to handle cell arrays of strings. | |
45 retval = strcmp (lower (s1), lower (s2)); | |
46 else | |
47 retval = false; | |
48 endif | |
5186 | 49 else |
6046 | 50 print_usage (); |
5185 | 51 endif |
52 | |
53 endfunction | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
54 |
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7017
diff
changeset
|
55 %!assert (strcmpi("abc123", "ABC123"), logical(1)); |