- Documentation
- Server functions
- pregMatch
Function
pregMatch
Returns all regular expression matches in a text. When the pattern has groups in brackets, each match is a table: the whole match followed by the groups.
Syntax
table pregMatch(string base, string pattern [, string/int flags = "", int maxResults = 100000])Arguments
basestring- The text.
patternstring- Regular expression.
flagsstring/int, optional = ""- Flags (as in
pregFind). maxResultsint, optional = 100000- Maximum number of results.
Returns
A table of matches (empty when none), or false for an invalid pattern.
Example
local text = "Kontakt: 123-456-789 lub 987-654-321"
for _, number in ipairs(pregMatch(text, "\\d{3}-\\d{3}-\\d{3}")) do outputServerLog(number) end