Garry's Mod Wiki

Revision Difference

string.gmatch#528453

<function name="gmatch" parent="string" type="libraryfunc"> <description>Using <page>Patterns</page>, returns an iterator which will return either one value if no capture groups are defined, or any capture group matches.</description> <realm>Shared and Menu</realm> <args> <arg name="data" type="string">The string to search in</arg> <arg name="pattern" type="string">The pattern to search for</arg> </args> <rets> <ret name="" type="function">The iterator function that can be used in a for-in loop</ret> </rets> </function> <example> <description>Explodes the string for each space and comma in the string</description> <code> str = "qwe,a cde" for s in string.gmatch(str, "[^%s,]+") do print(s) end </code> <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output> ```⤶ qwe a cde ```⤶ </output> </example>