re:match |
---|
Summary Matches a regexp to a string Prototype
Description This takes a regular expression object compiled previously with rex.new, and matches it against a target string.
If you are planning to do multiple matches against the same regular expression, it is faster to compile once only (ie. do rex.new once), and test multiple times. However for once-off tests you can combine them both into the same line:
The third result returned is a table of capture patterns that have been matched. Example:
Output from table.foreach: 1 Nick 2 East where East who Nick This shows that the 2 capture patterns (the things in round brackets) have been captured in the table as index 1 and 2 (first and second pattern) and also under named indices "where" and "who" because we used named capture patterns in the regular expression. See Also ... Lua functions
re:exec - Matches a regexp to a string, returning offsets
Topics
Lua base functions
(Help topic: lua=re:match) |
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.