String
string.lower
Shared
Converts all uppercase letters to lowercase
Syntax
local result = string.lower(input)Parameters
| Type | Name | Description |
|---|---|---|
string | input | String to be converted |
Returns
| Type | Name | Description |
|---|---|---|
string | result | Altered string with all uppercase letters converted to lowercase |
Examples
--Convert to lowercase
local result = string.lower("HELLO")
engine.print(result) --hello--Mixed case
local result = string.lower("Hello World")
engine.print(result) --hello world--Already lowercase (no change)
local result = string.lower("already lowercase")
engine.print(result) --already lowercase--Numbers and special characters unchanged
local result = string.lower("ABC123!@#")
engine.print(result) --abc123!@#--Case-insensitive comparison
local str1 = "Hello"
local str2 = "HELLO"
if string.lower(str1) == string.lower(str2) then
engine.print("Strings are equal (case-insensitive)")
end--Normalize user input
local input = "YES"
if string.lower(input) == "yes" then
engine.print("User confirmed")
end--Convert keys to lowercase
local data = {
Name = "John",
Age = 25,
City = "NYC"
}
for key, value in pairs(data) do
engine.print(string.lower(key), value)
end
--Output: name John, age 25, city NYC--Email normalization
local email = "User@Example.COM"
local normalized = string.lower(email)
engine.print(normalized) --user@example.com--String with only numbers (no change)
local result = string.lower("123456")
engine.print(result) --123456--Empty string
local result = string.lower("")
engine.print(result) ----Chaining with other string functions
local result = string.lower("HELLO WORLD"):gsub(" ", "_")
engine.print(result) --hello_world