如果我有这样的字符串。
local string = "D:/Test/Stuff/Server/resources/[Test]/SuperTest"
我该如何删除单词";服务器";所以它最终会看起来像这个
local string = "D:/Test/Stuff/Server"
使用str而不是string来不隐藏真实的字符串库
local str = "D:/Test/Stuff/Server/resources/[Test]/SuperTest"
这里是的解决方案
str = str:match("(.*Server)")
或者使用do结束以避免跟踪
do
local string = ("D:/Test/Stuff/Server/resources/[Test]/SuperTest"):match("(.*Server)")
end