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 Name | Type | Description |
---|
message | string | The message to match the pattern within. |
pattern | string | The pattern to match. |
flags | number | [Optional] The regex flags to use while matching. |
Returns |
---|
(table | nil) Table containing the matches on success, nil otherwise. |
search
Returns any matches to the given pattern on the given string. (Uses std::regex_search)
1table|nil hook.regex.search(message, pattern, flags);
Parameter Name | Type | Description |
---|
message | string | The message to match the pattern within. |
pattern | string | The pattern to match. |
flags | number | [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 Name | Type | Description |
---|
message | string | The message to replace the pattern within. |
pattern | string | The pattern to match. |
replace | string | The replacement string. |
flags | number | [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 Name | Type | Description |
---|
message | string | The message to replace the pattern within. |
pattern | string | The pattern to match. |
replace | function | The replacement function to invoke when a match is found to be replaced. |
flags | number | [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 Name | Type | Description |
---|
message | string | The message to split. |
pattern | string | The pattern to match. |
flags | number | [Optional] The regex flags to use while matching. |
Returns |
---|
(table | nil) Table containing the split parts on success, nil otherwise. |