### 5.5 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 ]

`tf =` isalnum `(s)` ¶

  Return a logical array which is true where the elements of s are letters or digits and false where they are not.

  This is equivalent to (`isalpha (s) | isdigit (s)`).

  See also: isalpha, isdigit, ispunct, isspace, iscntrl.

`tf =` isalpha `(s)` ¶

  Return a logical array which is true where the elements of s are letters and false where they are not.

  This is equivalent to (`islower (s) | isupper (s)`).

  See also: isdigit, ispunct, isspace, iscntrl, isalnum, islower, isupper.

`tf =` isletter `(s)` ¶

  Return a logical array which is true where the elements of s are letters and false where they are not.

  This is an alias for the `isalpha` function.

  See also: isalpha, isdigit, ispunct, isspace, iscntrl, isalnum.

`tf =` islower `(s)` ¶

  Return a logical array which is true where the elements of s are lowercase letters and false where they are not.

  See also: isupper, isalpha, isletter, isalnum.

`tf =` isupper `(s)` ¶

  Return a logical array which is true where the elements of s are uppercase letters and false where they are not.

  See also: islower, isalpha, isletter, isalnum.

`tf =` isdigit `(s)` ¶

  Return a logical array which is true where the elements of s are decimal digits (0-9) and false where they are not.

  See also: isxdigit, isalpha, isletter, ispunct, isspace, iscntrl.

`tf =` isxdigit `(s)` ¶

  Return a logical array which is true where the elements of s are hexadecimal digits (0-9 and a-fA-F).

  See also: isdigit.

`tf =` ispunct `(s)` ¶

  Return a logical array which is true where the elements of s are punctuation characters and false where they are not.

  See also: isalpha, isdigit, isspace, iscntrl.

`tf =` isspace `(s)` ¶

  Return a logical array which is true where the elements of s are whitespace characters (space, formfeed, newline, carriage return, tab, and vertical tab) and false where they are not.

  See also: iscntrl, ispunct, isalpha, isdigit.

`tf =` iscntrl `(s)` ¶

  Return a logical array which is true where the elements of s are control characters and false where they are not.

  See also: ispunct, isspace, isalpha, isdigit.

`tf =` isgraph `(s)` ¶

  Return a logical array which is true where the elements of s are printable characters (but not the space character) and false where they are not.

  See also: isprint.

`tf =` isprint `(s)` ¶

  Return a logical array which is true where the elements of s are printable characters (including the space character) and false where they are not.

  See also: isgraph.

`tf =` isascii `(s)` ¶

  Return a logical array which is true where the elements of s are ASCII characters (in the range 0 to 127 decimal) and false where they are not.

`tf =` isstrprop `(str, prop)` ¶
`tf =` isstrprop `(str, prop, 'ForceCellOutput', flag)` ¶

  Test character string properties.

  For example:

      isstrprop ("abc123", "alpha")
      ⇒  [1, 1, 1, 0, 0, 0]

  If str is a cell array, `isstrpop` is applied recursively to each element of the cell array.

  Numeric arrays are converted to character strings.

  The second argument prop must be one of

  `"alpha"`

    True for characters that are alphabetic (letters).

  `"alnum"`
  `"alphanum"`

    True for characters that are alphabetic or digits.

  `"lower"`

    True for lowercase letters.

  `"upper"`

    True for uppercase letters.

  `"digit"`

    True for decimal digits (0-9).

  `"xdigit"`

    True for hexadecimal digits (a-fA-F0-9).

  `"space"`
  `"wspace"`

    True for whitespace characters (space, formfeed, newline, carriage return, tab, vertical tab).

  `"punct"`

    True for punctuation characters (printing characters except space or letter or digit).

  `"cntrl"`

    True for control characters.

  `"graph"`
  `"graphic"`

    True for printing characters except space.

  `"print"`

    True for printing characters including space.

  `"ascii"`

    True for characters that are in the range of ASCII encoding.

  If the option `'ForceCellOutput'` is given and flag is true then a cell value is returned rather than a logical array.

  See also: isalpha, isalnum, islower, isupper, isdigit, isxdigit, isspace, ispunct, iscntrl, isgraph, isprint, isascii.