Commit 6c8a3e77 authored by Geoff Simmons's avatar Geoff Simmons

Add the .re_match() method.

parent 4a899580
......@@ -32,6 +32,7 @@ CONTENTS
* :ref:`func_set.match`
* :ref:`func_set.matched`
* :ref:`func_set.nmatches`
* :ref:`func_set.re_match`
* :ref:`func_set.string`
* :ref:`func_set.which`
* :ref:`func_version`
......@@ -239,6 +240,28 @@ Example::
}
.. _func_set.re_match:
BOOL xset.re_match(STRING subject, INT n, ENUM select)
------------------------------------------------------
::
BOOL xset.re_match(
STRING subject,
INT n=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE
)
Returns ...
Example::
if (myset.hasprefix(req.url)) {
# ...
}
.. _func_set.debug:
STRING xset.debug()
......
This diff is collapsed.
......@@ -616,6 +616,27 @@ vmod_set_string(VRT_CTX, struct vmod_selector_set * set, VCL_INT n,
return (s);
}
VCL_BOOL
vmod_set_re_match(VRT_CTX, struct vmod_selector_set *set, VCL_STRING subject,
VCL_INT n, VCL_ENUM selects)
{
unsigned idx;
vre_t *re;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(set, VMOD_SELECTOR_SET_MAGIC);
idx = get_idx(ctx, n, set, "re_match", selects);
if (idx == UINT_MAX)
return (0);
if (!check_added(ctx, set, idx, REGEX, "re_match", "regex"))
return (0);
re = set->table[idx]->re;
AN(re);
return (VRT_re_match(ctx, subject, re));
}
VCL_STRING
vmod_set_debug(VRT_CTX, struct vmod_selector_set *set)
{
......
......@@ -135,6 +135,18 @@ $Method STRING .string(INT n=0,
Returns ...
Example::
if (myset.hasprefix(req.url)) {
# ...
}
$Method BOOL .re_match(STRING subject, INT n=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST}
select=UNIQUE)
Returns ...
Example::
if (myset.hasprefix(req.url)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment