You can use the carot character ā^ā to anchor a search pattern to the start of a string.
Similarly the dollar sign ā$ā can be used to anchor a search pattern to the end of a string.
local s = " abc "
s = string.gsub(s, "^%s+", "")
print("'"..s.."'") --'abc '