Next: , Previous: , Up: Library   [Contents][Index]


5.6 Character Type

These functions check whether all characters of str fall into a certain character class according to the ‘C’ (‘POSIX’) locale23. ‘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: boolean isalnum (string str)

Checks for alphanumeric characters:

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

Checks for an alphabetic character:

  isalnum("abc") ⇒ 1
  isalnum("a123") ⇒ 0
Built-in Function: boolean 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: boolean isblank (string str)

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

Built-in Function: boolean iscntrl (string str)

Checks for control characters.

Built-in Function: boolean isdigit (string str)

Checks for digits (0 through 9).

Built-in Function: boolean isgraph (string str)

Checks for any printable characters except spaces.

Built-in Function: boolean islower (string str)

Checks for lower-case characters.

Built-in Function: boolean isprint (string str)

Checks for printable characters including space.

Built-in Function: boolean ispunct (string str)

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

Built-in Function: boolean 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: boolean isupper (string str)

Checks for uppercase letters.

Built-in Function: boolean 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

(23)

Support for other locales is planned for future versions.


Next: , Previous: , Up: Library   [Contents][Index]