4.12.1.4 Character Type

These functions check whether all characters of str fall into a certain character class according to the ‘C’ (‘POSIX’) locale(16). ‘True’ (1) is returned if they do, ‘false’ (0) is returned otherwise. In the latter case, the global variable ctype_mismatch is set to the index of the first character that is outside of the character class (characters are indexed from 0).

Built-in Function: number isalnum (string str)

Checks for alphanumeric characters:

 
  isalnum("a123") ⇒ 1
  isalnum("a.123") ⇒ 0 (ctype_mismatch = 1)
Built-in Function: number isalpha (string str)

Checks for an alphabetic character:

 
  isalnum("abc") ⇒ 1
  isalnum("a123") ⇒ 0
Built-in Function: number isascii (string str)

Checks whether all characters in str are 7-bit ones, that fit into the ASCII character set.

 
  isascii("abc") ⇒ 1
  isascii("ab\0200") ⇒ 0
Built-in Function: number isblank (string str)

Checks if str contains only blank characters; that is, spaces or tabs.

Built-in Function: number iscntrl (string str)

Checks for control characters.

Built-in Function: number isdigit (string str)

Checks for digits (0 through 9).

Built-in Function: number isgraph (string str)

Checks for any printable characters except spaces.

Built-in Function: number islower (string str)

Checks for lower-case characters.

Built-in Function: number isprint (string str)

Checks for printable characters including space.

Built-in Function: number ispunct (string str)

Checks for any printable characters which are not a spaces or alphanumeric characters.

Built-in Function: number isspace (string str)

Checks for white-space characters, i.e.: space, form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’).

Built-in Function: number isupper (string str)

Checks for uppercase letters.

Built-in Function: number isxdigit (string str)

Checks for hexadecimal digits, i.e. one of ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’.

Footnotes

(16)

Support for other locales is planned for future versions.