Type Function Library string.* Return value pattern-finding iterator Revision 2017.3060 Keywords string, match, patterns, gmatch See also string.find() string.gsub() string.match()
Returns a pattern-finding iterator. See Lua String Manipulation for more information.
string.gmatch( s, pattern ) s:gmatch( pattern )
String. The string to be searched.
String. A string specifying the pattern to match. See Lua String Manipulation for more information.
-- 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