Lua如何从字符串中删除撇号
所以我对Lua gsub从字符串中删除撇号有一个问题,如果有一个撇号,或者有很多撇号,我似乎无法让它删除任何撇号Lua如何从字符串中删除撇号,lua,Lua,所以我对Lua gsub从字符串中删除撇号有一个问题,如果有一个撇号,或者有很多撇号,我似乎无法让它删除任何撇号 local uri_without_args = "'" --one on its own local uri_without_args = "''''''''lol''''" --in text local uri_without_args = "''''''''''''" --loads --etc--etc all occurrences must go local list
local uri_without_args = "'" --one on its own
local uri_without_args = "''''''''lol''''" --in text
local uri_without_args = "''''''''''''" --loads
--etc--etc all occurrences must go
local list = {
"%'", --apostrophe
}
for k,v in ipairs(list) do
local uri_without_args_remove_duplicates, occurrences = uri_without_args:gsub(""..v.."","")
if occurrences > 0 then
occurrences = occurrences + 1
for i=1, occurrences do
if uri_without_args_remove_duplicates=="" then
--do nothing
else
uri_without_args = uri_without_args:gsub(""..v.."","")
end
end
end
end
print(uri_without_args)
只有当
uri\u(不带参数)
不为空时,才能为uri\u(不带参数)
分配新值。如果您从分配给uri\u而不带参数的If
语句中删除If
,或者如果uri\u而不带参数的以“lol”
开头,那么它可以正常工作
正如Egor在评论中所说,您也可以简单地使用uri\u(不带参数)\u remove\u duplicates
作为结果值。唯一一次为uri\u(不带参数)
指定新值的时候是uri\u(不带参数)\u remove\u duplicates
不为空。如果您从分配给uri\u而不带参数的If
语句中删除If
,或者如果uri\u而不带参数的以“lol”
开头,那么它可以正常工作
正如Egor在评论中所说的,您也可以简单地使用uri\u而不使用args\u remove\u duplicates
作为结果值。您的变量uri\u而不使用args\u remove\u duplicates
包含正确的结果,但您既不保存也不打印它。您的变量uri\u而不使用args\u remove\u duplicates
包含正确的结果,但是您既没有保存也没有打印它。我按照建议删除了if语句,现在可以正常工作了谢谢:)我按照建议删除了if语句,现在可以正常工作了谢谢:)