Garry's Mod Wiki

string.gfind

  function string.gfind( string data, string pattern )

Description

We advise against using this. It may be changed or removed in a future update. This function is removed in Lua versions later than what GMod is currently using. Use string.gmatch instead.

Returns an iterator function that is called for every complete match of the pattern, all sub matches will be passed as to the loop.

Arguments

1 string data
The string to search in
2 string pattern
The pattern to search for

Returns

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

Example

Example usage of the function

local s = "my awesome stuff 12" for w in string.gfind(s, "(%a)") do Msg(w) end
Output: In your console: myawesomestuff