local _t = {} _t.name = "Li" _t.age = 49 local str = string.gsub("hahah---[name]----[age]--xrz-", "[%[](.-)[%]]", function(s) return tostring(_t[s]) end) print(str)