MATLAB Function Reference Previous page   Next Page
isstrprop

Determine if string is of specified category

Syntax

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:

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:

Test for white-space characters in a string:

See Also

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


Previous page  isstr isstruct Next page

© 1994-2005 The MathWorks, Inc.