This module provides some new functionality:
ctype.isAlnum()
ctype.isAlpha()
ctype.isCntrl()
ctype.isDigit()
ctype.isGraph()
ctype.isLower()
ctype.isPrint()
ctype.isPunct()
ctype.isSpace()
ctype.isUpper()
ctype.isHex()
All function calls will expect a string value and will return a boolean value.
Checks for just alphanumeric characters.
Example:
local ctype = require("ctype")
if ctype.isAlnum("ABC12345")
then
print("Yes")
else
print("No")
end
Checks for just alphabetic characters.
Example:
local ctype = require("ctype")
if ctype.isAlpha("ABCabc")
then
print("Yes")
else
print("No")
end
Checks for just control characters.
Example:
local ctype = require("ctype")
if ctype.isCntrl("\n\r\t")
then
print("Yes")
else
print("No")
end
Checks for just numerical characters.
Example:
local ctype = require("ctype")
if ctype.isDigit("12345")
then
print("Yes")
else
print("No")
end
Checks for any printable characters except space.
Example:
local ctype = require("ctype")
if ctype.isGraph("ABC")
then
print("Yes")
else
print("No")
end
Checks for just lowercase characters.
Example:
local ctype = require("ctype")
if ctype.isLower("abc")
then
print("Yes")
else
print("No")
end
Checks for just printable characters.
Example:
local ctype = require("ctype")
if ctype.isPrint("Lee")
then
print("Yes")
else
print("No")
end
Checks for any printable characters which are not whitespace or alphanumeric character.
Example:
local ctype = require("ctype")
if ctype.isPunct("@")
then
print("Yes")
else
print("No")
end
Checks for just whitespace characters.
Example:
local ctype = require("ctype")
if ctype.isSpace(" ")
then
print("Yes")
else
print("No")
end
Checks for just uppercase characters.
Example:
local ctype = require("ctype")
if ctype.isUpper("ABCDEFGH")
then
print("Yes")
else
print("No")
end
Checks for just characters representing a hexadecimal digit.
Example:
local ctype = require("ctype")
if ctype.isHex("ABCDEF0123456789")
then
print("Yes")
else
print("No")
end
Standard
git clone git:https://github.com/mostvotedplaya/Lua-Ctype.git
cd Lua-Ctype/src
make
make install
Luarocks
luarocks install --server=https://luarocks.org/dev luactype