The is module implements functions for checking the contents of strings.
The is module does not depend on other modules.
Function | Purpose |
---|---|
is_alnum() | Check if a string contains only alphanumeric characters |
is_alpha() | Check if a string contains only alphabet characters |
is_base64() | Check if a string contains a base64-encoded value |
is_digits() | Check if a string contains only digits |
is_hex() | Check if a string contains a hexadecimal value |
is_int() | Check if a string contains an integer value |
is_lower() | Check if a string contains only lower-case letters |
is_upper() | Check if a string contains only upper-case letters |
Check if a string contains only alphanumeric characters
is_alnum "$str"
The is_alnum()
function tests whether all characters in the string $str
are alphanumeric.
Return value | Meaning |
---|---|
0 | The input is alphanumeric |
1 | The input is not alphanumeric |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains only alphabet characters
is_alpha "$str"
The is_alpha()
function tests whether all characters in the string $str
are alphabet characters.
Return value | Meaning |
---|---|
0 | The input is alphabetic |
1 | The input is not alphabetic |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains a base64-encoded value
is_base64 "$str"
The is_base64()
function tests whether the string $str
contains a base64-encoded value. Aside of upper and
lower-case alphabet letters and digits, /
and +
are considered part of the base64-alphabet. This function
does not check if the length of the padding is correct.
Return value | Meaning |
---|---|
0 | The input is base64 |
1 | The input is not base64 |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains only digits
is_digits "$str"
The is_digits()
function tests whether all characters in the string $str
are digits.
Return value | Meaning |
---|---|
0 | The input contains only digits |
1 | The input contains non-digit characters |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains a hexadecimal value
is_hex "$str"
The is_hex()
function tests whether the string $str
contains a hexadecimal value. The value must neither
be prefixed with 0x
or 0X
, nor suffixed with h
or H
.
Return value | Meaning |
---|---|
0 | The input is hexadecimal |
1 | The input is not hexadecimal |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains an integer value
is_int "$str"
The is_int()
function tests whether the string $str
contains an integer value. This function is similar to
is_digits()
, except that it allows the value to be prefixed with a sign (either +
or -
).
Return value | Meaning |
---|---|
0 | The input is an integer |
1 | The input is not an integer |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains only lower-case letters
is_lower "$str"
The is_lower()
function tests whether all characters in the string $str
are lower-case alphabet letters.
Return value | Meaning |
---|---|
0 | The input is lower-case |
1 | The input is not lower-case |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.
Check if a string contains only upper-case letters
is_upper "$str"
The is_upper()
function tests whether all characters in the string $str
are upper-case alphabet letters.
Return value | Meaning |
---|---|
0 | The input is upper-case |
1 | The input is not upper-case |
This function does not read from standard input.
This function does not write to standard output.
This function does not write to standard error.