类型 函数 库 string.* 返回值 模式查找迭代器 修订 版本 2024.3703 关键词 字符串,匹配,模式,gmatch 另请参阅 string.find() string.gsub() string.match()
返回一个模式查找迭代器。有关更多信息,请参阅 Lua 字符串操作。
string.gmatch( s, pattern ) s:gmatch( pattern )
字符串。 要搜索的字符串。
-- Collect all key-value pairs from the given string into a table t = {} s = "from=world, to=Lua" for k, v in string.gmatch( s, "(%w+)=(%w+)" ) do t[k] = v end