annotate scripts/strings/isstrprop.m @ 12642:f96b9b9f141b stable

doc: Periodic grammarcheck and spellcheck of documentation. * func.txi: Correct two misspellings * cumtrapz.m, dblquad.m, quadgk.m, quadl.m, quadv.m, trapz.m, triplequad.m, cond.m, gmres.m, bzip2.m, compare_versions.m, getappdata.m, unpack.m, ver.m, glpk.m, pkg.m, axis.m, uigetdir.m, uigetfile.m, view.m, prctile.m, quantile.m, unidcdf.m, unidinv.m, isstrprop.m, balance.cc, besselj.cc, cellfun.cc, colamd.cc, dot.cc, eigs.cc, fftw.cc, matrix_type.cc, pinv.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, regexp.cc, schur.cc, time.cc (gmtime), typecast.cc urlwrite.cc bitfcns.cc (bitshift), data.cc (rem, norm, merge) debug.cc (dbstatus), dirfns.cc (glob), file-io.cc (freport), load-path.cc (genpath), load-save.cc (save), mappers.cc (islower, isupper, tolower, toupper) oct-hist.cc (edit_history), ov-fcn-inline.cc (vectorize), ov.cc (subsref), syscalls.cc (stat), variables.cc (whos, clear): Improve docstrings. Removed trailing whitespace characters on line.
author Rik <octave@nomad.inbox5.com>
date Sun, 01 May 2011 11:39:50 -0700
parents 5ec6aa05638d
children e84d512b2438
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
1 ## Copyright (C) 2008-2011 John W. Eaton
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
20 ## @deftypefn {Function File} {} isstrprop (@var{str}, @var{prop})
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## Test character string properties. For example:
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 ## @example
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ## @group
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7530
diff changeset
25 ## isstrprop ("abc123", "alpha")
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 ## @result{} [1, 1, 1, 0, 0, 0]
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ## @end group
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 ## @end example
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
29 ##
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ## If @var{str} is a cell array, @code{isstrpop} is applied recursively
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 ## to each element of the cell array.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 ## Numeric arrays are converted to character strings.
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 ##
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
35 ## The second argument @var{prop} must be one of
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11591
diff changeset
37 ## @table @asis
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 ## @item "alpha"
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
39 ## True for characters that are alphabetic (letters).
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 ##
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 ## @item "alnum"
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 ## @itemx "alphanum"
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 ## True for characters that are alphabetic or digits.
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
44 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
45 ## @item "lower"
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
46 ## True for lowercase letters.
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
47 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
48 ## @item "upper"
12642
f96b9b9f141b doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
49 ## True for uppercase letters.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
50 ##
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 ## @item "digit"
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
52 ## True for decimal digits (0-9).
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
53 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
54 ## @item "xdigit"
11591
1d13679b587e Use @nospell macro on certain words in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
55 ## True for hexadecimal digits (@nospell{a-fA-F0-9}).
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
56 ##
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 ## @item "space"
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 ## @itemx "wspace"
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 ## True for whitespace characters (space, formfeed, newline, carriage
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 ## return, tab, vertical tab).
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
61 ##
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
62 ## @item "punct"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
63 ## True for punctuation characters (printing characters except space
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
64 ## or letter or digit).
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
65 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
66 ## @item "cntrl"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
67 ## True for control characters.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
68 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
69 ## @item "graph"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
70 ## @itemx "graphic"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
71 ## True for printing characters except space.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
72 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
73 ## @item "print"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
74 ## True for printing characters including space.
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
75 ##
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
76 ## @item "ascii"
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
77 ## True for characters that are in the range of ASCII encoding.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
78 ##
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 ## @end table
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 ##
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
81 ## @seealso{isalpha, isalnum, islower, isupper, isdigit, isxdigit,
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
82 ## isspace, ispunct, iscntrl, isgraph, isprint, isascii}
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 ## @end deftypefn
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
85 function retval = isstrprop (str, prop)
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 if (nargin == 2)
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
88 switch (prop)
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 case "alpha"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
90 retval = isalpha (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 case {"alnum", "alphanum"}
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
92 retval = isalnum (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 case "ascii"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
94 retval = isascii (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 case "cntrl"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
96 retval = iscntrl (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 case "digit"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
98 retval = isdigit (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 case {"graph", "graphic"}
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
100 retval = isgraph (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 case "lower"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
102 retval = islower (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 case "print"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
104 retval = isprint (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 case "punct"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
106 retval = ispunct (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 case {"space", "wspace"}
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
108 retval = isspace (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 case "upper"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
110 retval = isupper (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 case "xdigit"
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
112 retval = isxdigit (str);
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 otherwise
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
114 error ("isstrprop: invalid string property");
7530
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 endswitch
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 else
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 print_usage ();
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 endif
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
bb0f2353cff5 new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 endfunction
8442
502e58a0d44f Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 7530
diff changeset
121
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
122 %!error <invalid string property> isstrprop ("abc123", "foo")
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
123 %!assert (isstrprop ("abc123", "alpha"), logical ([1, 1, 1, 0, 0, 0]))
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
124 %!assert (isstrprop ("Hello World", "wspace"), isspace ("Hello World"))
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
125 %!assert (isstrprop ("Hello World", "graphic"), isgraph ("Hello World"))
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
126
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
127 %%Input Validation
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
128 %!error isstrprop ()
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
129 %!error isstrprop ("abc123")
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
130 %!error isstrprop ("abc123", "alpha", "alpha")