isstrprop
Classifies each character of a text by a property such as alphabetic or digit.
Category: Language Fundamentals > Data Types
Syntax
tf = isstrprop(str, category)
Returns a logical array that is true where the character belongs to category.
Description
isstrprop generalizes isletter and isspace: one call, many character classes. The categories are not mutually exclusive, for example a letter is both 'alpha' and 'alphanum', and a digit is both 'digit' and 'xdigit'.
Indexing the text with the result extracts or removes characters of a kind, such as s(isstrprop(s, 'digit')).
Input arguments
str- Character array.
category- One of
'alpha','alphanum','digit','lower','upper','punct','wspace','cntrl','graphic','print','ascii','xdigit'.
Output arguments
tf- Logical array the same size as
str.
Example
Digits and punctuation
s = 'Ab 1,!';
isstrprop(s, 'alpha')
isstrprop(s, 'punct')
s(isstrprop(s, 'digit'))
Output
ans = 1×6 logical array
1 1 0 0 0 0
ans = 1×6 logical array
0 0 0 0 1 1
ans = '1'