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
local result = string.lower("HELLO")
engine.print("info", result) --'hello'local result = string.lower("Hello World")
engine.print("info", result) --'hello world'local result = string.lower("already lowercase")
engine.print("info", result) --'already lowercase'local result = string.lower("ABC123!@#")
engine.print("info", result) --'abc123!@#'local str1 = "Hello"
local str2 = "HELLO"
if string.lower(str1) == string.lower(str2) then
engine.print("info", "Strings are equal (case-insensitive)")
endlocal input = "YES"
if string.lower(input) == "yes" then
engine.print("info", "User confirmed")
endlocal data = {
Name = "John",
Age = 25,
City = "NYC"
}
for key, value in pairs(data) do
engine.print("info", string.lower(key), value)
end
--[[
Output:
'name John'
'age 25'
'city NYC'
]]local email = "User@Example.COM"
local normalized = string.lower(email)
engine.print("info", normalized) --'user@example.com'local result = string.lower("123456")
engine.print("info", result) --'123456'local result = string.lower("")
engine.print("info", result) --''local result = string.lower("HELLO WORLD"):gsub(" ", "_")
engine.print("info", result) --'hello_world'