aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-30 13:48:34 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-30 13:48:34 +0100
commitf49a9fcbeccbde8cd1d6dfd4706bf7de0f737e24 (patch)
tree2d913299aaddd19bfbd322e59bf11b805932fcb4 /src/lua/lua_regexp.c
parentabbfcd0c515cfa0cd85ec3c87236f899a47c5f16 (diff)
downloadrspamd-f49a9fcbeccbde8cd1d6dfd4706bf7de0f737e24.tar.gz
rspamd-f49a9fcbeccbde8cd1d6dfd4706bf7de0f737e24.zip
Update documentation
Diffstat (limited to 'src/lua/lua_regexp.c')
-rw-r--r--src/lua/lua_regexp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index c405e33d8..60dbc5edc 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -274,19 +274,31 @@ lua_regexp_set_limit (lua_State *L)
}
/***
- * @method re:search(line)
+ * @method re:search(line[, raw[, capture]])
* Search line in regular expression object. If line matches then this
* function returns the table of captured strings. Otherwise, nil is returned.
+ * If `raw` is specified, then input is treated as raw data not encoded in `utf-8`.
+ * If `capture` is true, then this function saves all captures to the table of
+ * values, so the first element is the whole matched string and the
+ * subsequent elements are ordered captures defined within pattern.
*
* @param {string} line match the specified line against regexp object
- * @return {table or nil} table of strings matched or nil
+ * @param {bool} match raw regexp instead of utf8 one
+ * @param {bool} capture perform subpatterns capturing
+ * @return {table or nil} table of strings or tables (if `capture` is true) or nil if not matched
* @example
* local re = regexp.create_cached('/^\s*([0-9]+)\s*$/')
* -- returns nil
* local m1 = re:search('blah')
* local m2 = re:search(' 190 ')
- * -- prints '190'
+ * -- prints ' 190 '
* print(m2[1])
+ *
+ * local m3 = re:search(' 100500 ')
+ * -- prints ' 100500 '
+ * print(m3[1][1])
+ * -- prints '100500' capture
+ * print(m3[1][2])
*/
static int
lua_regexp_search (lua_State *L)