Version 0 of string is

Updated 2003-10-16 20:23:55

string is class ?-strict? ?-failindex varname? string

Returns 1 if string is a valid member of the specified character class, otherwise returns 0. If -strict is specified, then an empty string returns 0, otherwise an empty string will return 1 on any class. If -failindex is specified, then if the function returns 0, the index in the string where the class was no longer valid will be stored in the variable named varname. The varname will not be set if the function returns 1. The following character classes are recognized (the class name can be abbreviated):

alnum: Any Unicode alphabet or digit character.

alpha: Any Unicode alphabet character.

ascii: Any character with a value less than \u0080 (those that are in the 7-bit ascii range).

boolean: Any of the forms allowed to Tcl_GetBoolean.

control: Any Unicode control character.

digit: Any Unicode digit character. Note that this includes characters outside of the 0-9 range.

double: Any of the valid forms for a double in Tcl, with optional surrounding whitespace. In case of under/overflow in the value, 0 is returned and the varname will contain -1.

false: Any of the forms allowed to Tcl_GetBoolean where the value is false.

graph: Any Unicode printing character, except space.

integer: Any of the valid forms for an integer in Tcl, with optional surrounding whitespace. In case of under/overflow in the value, 0 is returned and the varname will contain -1.

lower: Any Unicode lower case alphabet character.

print: Any Unicode printing character, including space.

punct: Any Unicode punctuation character.

space: Any Unicode space character.

true: Any of the forms allowed to Tcl_GetBoolean where the value is true.

upper: Any upper case alphabet character in the Unicode character set.

wordchar: Any Unicode word character. That is any alphanumeric character, and any Unicode connector punctuation characters (e.g. underscore).

xdigit: Any hexadecimal digit character (0-9A-Fa-f).

In the case of boolean, true and false, if the function will return 0, then the varname will always be set to 0, due to the varied nature of a valid boolean value.


See also:


Tcl syntax help - Category Command