MATLAB Function Reference
isstrprop

Determine if string is of specified category

Syntax

• ```tf = isstrprop('str', '`category`')
```

Description

```tf = isstrprop('str', 'category') ``` returns a logical array the same size as `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:

 Category Description `alpha` `True` for those elements of `str` that are alphabetic `alphanum` `True` for those elements of `str` that are alphanumeric `cntrl` `True` for those elements of `str` that are control characters (for example, `char(0:20)`) `digit` `True` for those elements of `str` that are numeric digits `graphic` `True` for those elements of `str` that are graphic characters. These are all values that represent any characters except for the following:```unassigned, space, line separator, paragraph separator, control characters, Unicode format control characters, private user-defined characters, Unicode surrogate characters, Unicode other characters ``` `lower` `True` for those elements of `str` that are lowercase letters `print` `True` for those elements of `str` that are graphic characters, plus `char(32)` `punct` `True` for those elements of `str` that are punctuation characters `wspace` `True` for those elements of `str` that are white-space characters. This range includes the ANSI C definition of white space, `{' ','\t','\n','\r','\v','\f'}`. `upper` `True` for those elements of `str` that are uppercase letters `xdigit` `True` for those elements of `str` that are valid hexadecimal digits

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:

• ```A = isstrprop('abc123def', 'alpha')
A =
1 1 1 0 0 0 1 1 1
```

Test for numeric digits in a string:

• ```A = isstrprop('abc123def', 'digit')
A =
0 0 0 1 1 1 0 0 0
```

Test for hexadecimal digits in a string:

• ```A = isstrprop('abcd1234efgh', 'xdigit')
A =
1 1 1 1 1 1 1 1 1 1 0 0
```

Test 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 0
```

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:

• ```A = isstrprop(sprintf('a bc\n'), 'wspace')
A =
0 1 0 0 1
```

`ischar`, `isnumeric`, `isspace`, `iscellstr`, `isa`, is*