You can use the character test functions to check whether there are only certain characters in a string.
Function | Description |
---|---|
IsAscii (argument AS String) | |
Ascii? (argument AS string) | Returns True if the argument contains ASCII characters after it has been converted to a string. An ASCII character is a character whose code is less than or equal to 127. |
IsBlank (argument AS String) | |
Blank? (argument AS String) | Returns True if argument contains only spaces as string. A space is a space or the tab character. The line break \n and a return \r are not considered as spaces. |
IsDigit (argument AS String) | |
Digit? (argument AS String) | Returns True if the argument contains digits only. A digit is one of the following characters: 0 1 2 2 3 4 5 6 6 7 8 9. |
IsHexa (expression AS string) | |
Hexa? (Expression AS string) | Returns True if the expression contains only the following characters: 0 1 2 3 3 4 5 6 6 7 8 9 A B C D E F a b c d e f. |
IsLCase (argument AS String) | |
IsLower (argument AS String) | Returns True if the argument contains only ASCII lowercase letters. A lower case letter is one of the following characters: a b c c d e f g h i j k l l m n o p q r s t u w x y z. |
IsUCase (Exp AS String) | |
IsUpper (Exp AS String) | Returns True if the expression contains only ASCII capital letters. A capital letter is one of the following characters: A B C D E E F G H I J K L M N O P Q R S T U V W X X Y Z. Other characters are not considered capital letters. |
IsLetter (argument AS string) | Returns true if the argument contains only letters. A letter is one of the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz. |
IsPunct (Exp AS String) | Returns True if the expression contains punctuation characters only. A punctuation mark is one of the following:“! # $ % &' () ★ +,- /:;.? < = > @[ \] # { { } ~ Pipe Caret |
IsSpace (Exp AS String) | Returns True if the expression contains spaces only. The following characters are interpreted as blanks: Space, page feed Chr$ (12), line break “\n”, carriage return (CR)“\r”, horizontal tab “\t” and the vertical tab Chr$ (11). |
Table 9.4.1: Overview of the character test functions
Examples:
PRINT IsAscii("Gambas"), IsAscii(Now), IsAscii(188), IsAscii("Benoît") True True True False PRINT IsBlank(" \t"), IsBlank("Test") True False PRINT IsDigit("2014"), IsDigit("123a") True False Print IsHexa("C3DDFF"), IsHexa("Bad") True True Print IsHexa("GAMBAS"), IsHexa(""), IsHexa(Zero), IsHexa("Arie") False False False False Print IsLCase("small"), IsLCase("big"), IsLCase("123a") True False False Print IsUCase("GAMBAS"), IsUCase("ANGER") True False Print IsPunct(":-)"), IsPunct(":-p") True False PRINT IsLetter("Gambas?"), IsLetter("Yes - Gambas!"), IsLetter("Correct") False False True Print "IsSpace = "; IsSpace(" \\n \\r\\n"), IsSpace(gb.NewLine) IsSpace = False True