Empty strings

Basic types / Strings

-- Empty string literal
local some_empty_string = ""

-- Compare with "" or check the length
local is_empty = some_empty_string == ""
-- is_empty = true
local zero_length = #some_empty_string == 0
-- zero_length = true

-- Spaces are not empty
local spaces = "   "
local spaces_empty = spaces == ""
-- spaces_empty = false

-- %S is any non-space character
local spaces_blank = spaces:find("%S") == nil
-- spaces_blank = true

print("is_empty = " .. tostring(is_empty))
print("zero_length = " .. tostring(zero_length))
print("spaces_empty = " .. tostring(spaces_empty))
print("spaces_blank = " .. tostring(spaces_blank))