MATLAB Function Reference |
Determine if string is of specified category
Syntax
Description
tf = isstrprop('str', '
returns a logical array the same size as category
')
str
containing logical 1
(true
) where the elements of str
belong to the specified category
, and logical 0
(false
) where they do not.
The str
input can be a character array, cell array, or any MATLAB numeric type. If str
is a cell array, then the return value is a cell array of the same shape as str
.
The category
input can be any of the strings shown in the left column below:
Remarks
Numbers of type double
are converted to int32
according to MATLAB rules of double-to-integer conversion. Numbers of type int64
and uint64
bigger than int32(inf)
saturate to int32(inf)
.
MATLAB classifies the elements of the str
input according to the Unicode definition of the specified category. If the numeric value of an element in the input array falls within the range that defines a Unicode character category, then this element is classified as being of that category. The set of Unicode character codes includes the set of ASCII character codes, but also covers a large number of languages beyond the scope of the ASCII set. The classification of characters is dependent on the global location of the platform on which MATLAB is installed.
Examples
Test for alphabetic characters in a string:
Test for numeric digits in a string:
Test for hexadecimal digits in a string:
Test for numeric digits in a character array:
Test for alphabetic characters in a two-dimensional cell array:
A = isstrprop({'abc123def';'456ghi789'}, 'alpha') A = [1x9 logical] [1x9 logical] A{:,:} ans = 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0
Test for white-space characters in a string:
See Also
ischar
, isnumeric
, isspace
, iscellstr
, isa
, is*
isstr | isstruct |
© 1994-2005 The MathWorks, Inc.