gmatch

Definition: include builtins\regex.e

string res = gmatch(string re, string target, string res)
Description: Draft - this is a very simple routine that took very little time or effort (or thought) to write, and may change in later releases.

Applies the regular expression re (in string or pre-compiled format) to target and returns res with any substitutions for \1 to \9, or -1 if no match could be found.

re: a regular expression such as "a(b*)" or the result of applying regex_compile() to such a string.
target: a string to be matched against the regular expression.
res: a string containing \1 to \9 that should be replaced with the results of any match.

Returns: an updated res or -1 if no match could be found.
Example:
?gmatch(`(\w+) changed to (\w+)`,"red changed to green",`\2 <- \1`) -- yields "green <- red"
See Also: gsub