regexp_gmatch(string, pattern)

Return an iterator function that can be used in a for loop to process each substring matched by the regular expression pattern.

Example

t={}
for word in regexp_gmatch("the quick brown fox", "[a-zA-Z]+") do
    t[#t+1] = word
end