Character Class Functions Previous: String Conversions Up: Strings



Character Class Functions

Octave also provides the following character class test functions patterned after the functions in the standard C library. They all operate on string arrays and return matrices of zeros and ones. Elements that are nonzero indicate that the condition was true for the corresponding character in the string array. For example

     isalpha ("!Q@WERT^Y&")
          => [ 0 1, 0, 1, 1, 1, 1, 0, 1, 0 ]
     

isalnum (s) Mapping Function
Return 1 for characters that are letters or digits (isalpha (s) or isdigit (s) is true).

isalpha (s) Mapping Function
isletter (s) Mapping Function
Return true for characters that are letters (isupper (s) or islower (s) is true).

isascii (s) Mapping Function
Return 1 for characters that are ASCII (in the range 0 to 127 decimal).

iscntrl (s) Mapping Function
Return 1 for control characters.

isdigit (s) Mapping Function
Return 1 for characters that are decimal digits.

isgraph (s) Mapping Function
Return 1 for printable characters (but not the space character).

islower (s) Mapping Function
Return 1 for characters that are lower case letters.

isprint (s) Mapping Function
Return 1 for printable characters (including the space character).

ispunct (s) Mapping Function
Return 1 for punctuation characters.

isspace (s) Mapping Function
Return 1 for whitespace characters (space formfeed, newline, carriage return tab, and vertical tab).

isupper (s) Mapping Function
Return 1 for upper case letters.

isxdigit (s) Mapping Function
Return 1 for characters that are hexadecimal digits.