string.gmatch

From Garry's Mod
Jump to: navigation, search
 string.gmatch( )

Contents

Description

Using Patterns, returns an iterator which will return either one value if no capture groups are defined, or any capture group matches.

Arguments

string data

The string to search in

Arguments

string pattern

The pattern to search for

Returns

function

The iterator function that can be used in a for-in loop

Examples

Example

Explodes the string for each space and comma in the string

str = "qwe,a cde"
for s in string.gmatch(str, "[^%s,]+") do
    print(s)
end

Output:

qwe
a
cde
Personal tools
Navigation