This shows you the differences between two versions of the page.
— |
addons:functions:regex [2017/04/22 01:28] (current) atom0s created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Regex Namespace ===== | ||
+ | |||
+ | The regex namespace contains functions that expose C++ regex functionality to Lua. Due to Lua's limited regular expression functions, users may need some better regex support from C++ which this namespace provides. | ||
+ | |||
+ | You can access these functions via: | ||
+ | <sxh lua>ashita.regex.</sxh> | ||
+ | |||
+ | ---- | ||
+ | ==== ashita.regex.match ==== | ||
+ | |||
+ | Matches a given pattern. (Calls std::regex_match) | ||
+ | <sxh lua>table ashita.regex.match(message, pattern);</sxh> | ||
+ | * **Parameters** | ||
+ | * message - (string) The message to search within. | ||
+ | * pattern - (string) The pattern to match. | ||
+ | * **Returns** | ||
+ | * table - A table of the match information, nil on error. | ||
+ | |||
+ | ---- | ||
+ | ==== ashita.regex.search ==== | ||
+ | |||
+ | Searches for a given pattern. (Calls std::regex_search) | ||
+ | <sxh lua>table ashita.regex.match(message, pattern);</sxh> | ||
+ | * **Parameters** | ||
+ | * message - (string) The message to search within. | ||
+ | * pattern - (string) The pattern to match. | ||
+ | * **Returns** | ||
+ | * table - A table of the match information, nil on error. | ||
+ | |||
+ | ---- | ||
+ | ==== ashita.regex.replace ==== | ||
+ | |||
+ | Replaces matches found within a message.. (Calls std::regex_replace) | ||
+ | <sxh lua>string ashita.regex.replace(message, pattern, rep);</sxh> | ||
+ | * **Parameters** | ||
+ | * message - (string) The message to search within. | ||
+ | * pattern - (string) The pattern to match. | ||
+ | * rep - (string) The string to replace when the pattern is found. | ||
+ | * **Returns** | ||
+ | * string - The replaced string, nil on error. | ||
+ | |||
+ | ---- | ||
+ | ==== ashita.regex.split ==== | ||
+ | |||
+ | Splits a string based on a pattern. (Calls std::sregex_token_iterator) | ||
+ | <sxh lua>table ashita.regex.replace(message, pattern, rep);</sxh> | ||
+ | * **Parameters** | ||
+ | * message - (string) The message to search within. | ||
+ | * pattern - (string) The pattern to match. | ||
+ | * **Returns** | ||
+ | * table - The split parts found from the pattern, nil on error. | ||