Lua替换字符串

代码:

local str = "This is a test string with AA and another AA."

-- 使用全词匹配查找并替换
-- 注意:Lua的标准正则表达式不支持单词边界`\\b`,所以我们需要使用其他方法
local new_str = str:gsub(" AA ", " BB ")

print(new_str)

 

posted @ 2024-06-20 16:26  朱小勇  阅读(9)  评论(0编辑  收藏  举报