Determine if string is of specified category
tf = isstrprop('str', 'category')
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, string
array, cell array, or any MATLAB® numeric type. If str is
a cell array or a nonscalar string array, then the return value is
a cell array of the same shape as str.
The category input can be any of
the categories shown in the left column below:
Category | Description |
|---|---|
|
|
|
|
|
|
|
|
| True for those elements of unassigned, space, line separator, paragraph separator, control characters, Unicode format control characters, private user-defined characters, Unicode surrogate characters, Unicode other characters |
|
|
|
|
|
|
|
|
|
|
|
|
Test for alphabetic characters in a character vector:
A = isstrprop('abc123def', 'alpha')
A =
1 1 1 0 0 0 1 1 1Test for numeric digits in a character vector:
A = isstrprop('abc123def', 'digit')
A =
0 0 0 1 1 1 0 0 0Test for hexadecimal digits in a character vector:
A = isstrprop('abcd1234efgh', 'xdigit')
A =
1 1 1 1 1 1 1 1 1 1 0 0Test for numeric digits in a character array:
A = isstrprop(char([97 98 99 49 50 51 101 102 103]), ...
'digit')
A =
0 0 0 1 1 1 0 0 0Test 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 0Test for white-space characters in a character vector:
A = isstrprop(sprintf('a bc\n'), 'wspace')
A =
0 1 0 0 1