lua正则表达式替换字符串

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)

猜你喜欢

转载自www.cnblogs.com/sanyejun/p/11589933.html
今日推荐