regex

The regex namespace contains functions that allow for more advanced regular expression usage.

These file system functions make use of the C++ std::regex header. The functions are named the same/similar.
For more information on those functions, please visit: https://en.cppreference.com/w/cpp/regex

Functions exposed by this namespace are accessed via the prefix: hook.regex.

Functions

match

Returns any matches to the given pattern on the given string. (Uses std::regex_match)

1table|nil hook.regex.match(message, pattern, flags);
Parameter NameTypeDescription
messagestringThe message to match the pattern within.
patternstringThe pattern to match.
flagsnumber[Optional] The regex flags to use while matching.
Returns
(table | nil) Table containing the matches on success, nil otherwise.

Returns any matches to the given pattern on the given string. (Uses std::regex_search)

1table|nil hook.regex.search(message, pattern, flags);
Parameter NameTypeDescription
messagestringThe message to match the pattern within.
patternstringThe pattern to match.
flagsnumber[Optional] The regex flags to use while matching.
Returns
(table | nil) Table containing the matches on success, nil otherwise.

replace

Returns a replaced string using the given pattern to make replacements. (Uses std::regex_replace)

1string|nil hook.regex.replace(message, pattern, replace, flags);
Parameter NameTypeDescription
messagestringThe message to replace the pattern within.
patternstringThe pattern to match.
replacestringThe replacement string.
flagsnumber[Optional] The regex flags to use while matching.
Returns
(string | nil) The replaced string on success, nil otherwise.
1string|nil hook.regex.replace(message, pattern, replace, flags);
Parameter NameTypeDescription
messagestringThe message to replace the pattern within.
patternstringThe pattern to match.
replacefunctionThe replacement function to invoke when a match is found to be replaced.
flagsnumber[Optional] The regex flags to use while matching.
Returns
(string | nil) The replaced string on success, nil otherwise.

split

Returns a table containing the parts of a split string. (Uses std::sregex_token_iterator)

1table|nil hook.regex.split(message, pattern, flags);
Parameter NameTypeDescription
messagestringThe message to split.
patternstringThe pattern to match.
flagsnumber[Optional] The regex flags to use while matching.
Returns
(table | nil) Table containing the split parts on success, nil otherwise.