Mercurial > octave
annotate scripts/strings/isstrprop.m @ 30330:01de0045b2e3
maint: Shorten some long lines to <= 80 characters (bug #57599)
* audiorecorder.m, disable_diagonal_matrix.m, disable_permutation_matrix.m,
disable_range.m, atan2d.m, accumdim.m, bitcmp.m, blkdiag.m, cplxpair.m,
dblquad.m, integral2.m, integral3.m, interp2.m, interpn.m, logspace.m,
delaunayn.m, griddata3.m, imread.m, genvarname.m, strread.m, nthargout.m,
parseparams.m, lsqnonneg.m, qp.m, sqp.m, material.m, __gnuplot_legend__.m,
plot.m, __gnuplot_drawnow__.m, polygcd.m, polyvalm.m, setdiff.m, fftfilt.m,
eigs.m, betainc.m, cosint.m, factor.m, gallery.m, toeplitz.m, discrete_cdf.m,
discrete_inv.m, discrete_pdf.m, iqr.m, kurtosis.m, quantile.m, bin2dec.m,
isstrprop.m, mat2str.m, strchr.m, strsplit.m, __have_feature__.m, datenum.m,
datevec.m, eomday.m, weboptions.m:
maint: Shorten some long lines to <= 80 characters.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 23 Nov 2021 13:28:34 -0800 |
parents | 7854d5752dd2 |
children | 83aeaba707d8 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2008-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7530 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7530 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7530 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7530 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
21 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7530 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20164
diff
changeset
|
27 ## @deftypefn {} {} isstrprop (@var{str}, @var{prop}) |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
28 ## Test character string properties. |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
29 ## |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## For example: |
7530 | 31 ## |
32 ## @example | |
33 ## @group | |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7530
diff
changeset
|
34 ## isstrprop ("abc123", "alpha") |
7530 | 35 ## @result{} [1, 1, 1, 0, 0, 0] |
36 ## @end group | |
37 ## @end example | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
38 ## |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
39 ## If @var{str} is a cell array, @code{isstrpop} is applied recursively to |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
40 ## each element of the cell array. |
7530 | 41 ## |
42 ## Numeric arrays are converted to character strings. | |
43 ## | |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
44 ## The second argument @var{prop} must be one of |
7530 | 45 ## |
11595
5ec6aa05638d
Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents:
11591
diff
changeset
|
46 ## @table @asis |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
47 ## @item @qcode{"alpha"} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
48 ## True for characters that are alphabetic (letters). |
7530 | 49 ## |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
50 ## @item @nospell{@qcode{"alnum"}} |
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
51 ## @itemx @nospell{@qcode{"alphanum"}} |
7530 | 52 ## 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
|
53 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
54 ## @item @qcode{"lower"} |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
55 ## True for lowercase letters. |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
56 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
57 ## @item @qcode{"upper"} |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11595
diff
changeset
|
58 ## True for uppercase letters. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
59 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
60 ## @item @qcode{"digit"} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
61 ## True for decimal digits (0-9). |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
62 ## |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
63 ## @item @nospell{@qcode{"xdigit"}} |
11591
1d13679b587e
Use @nospell macro on certain words in docstrings.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
64 ## 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
|
65 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
66 ## @item @qcode{"space"} |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
67 ## @itemx @nospell{@qcode{"wspace"}} |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
68 ## True for whitespace characters (space, formfeed, newline, carriage return, |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
69 ## tab, vertical tab). |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
70 ## |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
71 ## @item @nospell{@qcode{"punct"}} |
20164
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
72 ## True for punctuation characters (printing characters except space or |
df437a52bcaf
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
73 ## letter or digit). |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
74 ## |
25003
2365c2661b3c
doc: Spellcheck documentation ahead of 4.4 release.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
75 ## @item @nospell{@qcode{"cntrl"}} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
76 ## True for control characters. |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
77 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
78 ## @item @qcode{"graph"} |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
79 ## @itemx @qcode{"graphic"} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
80 ## True for printing characters except space. |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
81 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
82 ## @item @qcode{"print"} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
83 ## True for printing characters including space. |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
84 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17170
diff
changeset
|
85 ## @item @qcode{"ascii"} |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
86 ## 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
|
87 ## |
7530 | 88 ## @end table |
89 ## | |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
90 ## @seealso{isalpha, isalnum, islower, isupper, isdigit, isxdigit, |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
91 ## isspace, ispunct, iscntrl, isgraph, isprint, isascii} |
7530 | 92 ## @end deftypefn |
93 | |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
94 function retval = isstrprop (str, prop) |
7530 | 95 |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
96 if (nargin != 2) |
7530 | 97 print_usage (); |
98 endif | |
99 | |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
100 switch (prop) |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
101 case "alpha" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
102 retval = isalpha (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
103 case {"alnum", "alphanum"} |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
104 retval = isalnum (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
105 case "ascii" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
106 retval = isascii (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
107 case "cntrl" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
108 retval = iscntrl (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
109 case "digit" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
110 retval = isdigit (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
111 case {"graph", "graphic"} |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
112 retval = isgraph (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
113 case "lower" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
114 retval = islower (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
115 case "print" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
116 retval = isprint (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
117 case "punct" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
118 retval = ispunct (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
119 case {"space", "wspace"} |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
120 retval = isspace (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
121 case "upper" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
122 retval = isupper (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
123 case "xdigit" |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
124 retval = isxdigit (str); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
125 otherwise |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
126 error ("isstrprop: invalid string property"); |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
127 endswitch |
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
128 |
7530 | 129 endfunction |
8442
502e58a0d44f
Fix docstrings, add examples, references and tests to string functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7530
diff
changeset
|
130 |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
131 |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
132 %!assert (isstrprop ("abc123", "alpha"), logical ([1, 1, 1, 0, 0, 0])) |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
133 %!assert (isstrprop ("abc123", "digit"), logical ([0, 0, 0, 1, 1, 1])) |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
134 %!assert (isstrprop ("Hello World", "wspace"), isspace ("Hello World")) |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
135 %!assert (isstrprop ("Hello World", "graphic"), isgraph ("Hello World")) |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
136 %!assert (isstrprop (char ("AbC", "123"), "upper"), logical ([1 0 1; 0 0 0])) |
30330
01de0045b2e3
maint: Shorten some long lines to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
137 %!assert (isstrprop ({"AbC", "123"}, "lower"), |
01de0045b2e3
maint: Shorten some long lines to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
138 %! {logical([0 1 0]), logical([0 0 0])}) |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
139 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
140 ## Test input validation |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
141 %!error <Invalid call> isstrprop () |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
142 %!error isstrprop ("abc123") |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
10821
diff
changeset
|
143 %!error isstrprop ("abc123", "alpha", "alpha") |
13312
e84d512b2438
isstrprop.m: Put input validation first and add a few more tests.
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
144 %!error <invalid string property> isstrprop ("abc123", "foo") |