Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re
Commits
d796f02e
Unverified
Commit
d796f02e
authored
Apr 05, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README
parent
9b531d22
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
README.rst
README.rst
+23
-13
No files found.
README.rst
View file @
d796f02e
...
@@ -24,9 +24,12 @@ SYNOPSIS
...
@@ -24,9 +24,12 @@ SYNOPSIS
import re;
import re;
# object interface
# object interface
new <obj> = re.regex(STRING, [, INT limit] [, INT limit_recursion])
new <obj> = re.regex(STRING, [, INT limit] [, INT limit_recursion]
[, BOOL forbody])
BOOL <obj>.match(STRING, [, INT limit] [, INT limit_recursion])
BOOL <obj>.match(STRING, [, INT limit] [, INT limit_recursion])
STRING <obj>.backref(INT [, STRING fallback])
STRING <obj>.backref(INT [, STRING fallback])
BOOL <obj>.match_body(req_body | bereq_body | resp_body,
[, INT limit] [, INT limit_recursion])
# function interface
# function interface
BOOL re.match_dyn(STRING, [, INT limit] [, INT limit_recursion])
BOOL re.match_dyn(STRING, [, INT limit] [, INT limit_recursion])
...
@@ -37,13 +40,17 @@ SYNOPSIS
...
@@ -37,13 +40,17 @@ SYNOPSIS
DESCRIPTION
DESCRIPTION
===========
===========
.. _regsub(): https://varnish-cache.org/docs/trunk/reference/vcl.html#regsub-str-regex-sub
.. _regsuball(): https://varnish-cache.org/docs/trunk/reference/vcl.html#regsuball-str-regex-sub
Varnish Module (VMOD) for matching strings against regular expressions,
Varnish Module (VMOD) for matching strings against regular expressions,
and for extracting captured substrings after matches.
and for extracting captured substrings after matches.
Regular expression matching as implemented by the VMOD is equivalent
Regular expression matching as implemented by the VMOD is equivalent
to VCL's infix operator ``~``. The VMOD is motivated by the fact that
to VCL's infix operator ``~``. The VMOD is motivated by the fact that
backreference capture in standard VCL requires verbose and suboptimal
backreference capture in standard VCL requires verbose and suboptimal
use of the `
`regsub`` or ``regsuball``
functions. For example, this
use of the `
regsub()`_ or `regsuball()`_
functions. For example, this
common idiom in VCL captures a string of digits following the
common idiom in VCL captures a string of digits following the
substring ``"bar"`` from one request header into another::
substring ``"bar"`` from one request header into another::
...
@@ -73,18 +80,21 @@ The equivalent solution with the VMOD looks like this::
...
@@ -73,18 +80,21 @@ The equivalent solution with the VMOD looks like this::
}
}
}
}
For an example on body matching, see `xregex.match_body()`_.
The object is created at VCL initialization with the regex containing
The object is created at VCL initialization with the regex containing
the capture expression, only describing the substring to be
the capture expression, only describing the substring to be
matched. When a match with the ``match`` method succeeds, then a
matched. When a match with the ``match`` or ``match_body`` method
captured string can be obtained from the ``backref`` method.
succeeds, then a captured string can be obtained from the ``backref``
method.
Calls to the ``backref`` method refer back to the most recent
Calls to the ``backref`` method refer back to the most recent
successful call to ``match``
for the same object in the same task
successful call to ``match``
or ``match_body`` for the same object in
scope; that is, in the same client or backend context. For example if
the same task scope; that is, in the same client or backend
``match`` is called for an object in one of the ``vcl_backend_*``
context. For example if ``match`` is called for an object in one of
subroutines and returns ``true``, then subsequent calls to ``backref``
the ``vcl_backend_*`` subroutines and returns ``true``, then
in the same backend scope extract substrings from the matched
subsequent calls to ``backref`` in the same backend scope extract
substring.
substring
s from the matched substring
.
The VMOD also supports dynamic regex matching with the ``match_dyn``
The VMOD also supports dynamic regex matching with the ``match_dyn``
and ``backref_dyn`` functions::
and ``backref_dyn`` functions::
...
@@ -262,7 +272,7 @@ Description
...
@@ -262,7 +272,7 @@ Description
scope (client or backend context), or a fallback string in
scope (client or backend context), or a fallback string in
case the extraction fails. Backref 0 indicates the entire
case the extraction fails. Backref 0 indicates the entire
matched string. Thus this function behaves like the ``\n``
matched string. Thus this function behaves like the ``\n``
symbols in `
`regsub`` and ``regsuball``
, and the ``$1``,
symbols in `
regsub()`_ and `regsuball()`_
, and the ``$1``,
``$2`` ... variables in Perl.
``$2`` ... variables in Perl.
After unsuccessful matches, the ``fallback`` string is returned
After unsuccessful matches, the ``fallback`` string is returned
...
@@ -270,7 +280,7 @@ Description
...
@@ -270,7 +280,7 @@ Description
is ``"**BACKREF METHOD FAILED**"``.
is ``"**BACKREF METHOD FAILED**"``.
The VCL infix operators ``~`` and ``!~`` do not affect this
The VCL infix operators ``~`` and ``!~`` do not affect this
method, nor do the functions `
`regsub`` or ``regsuball``
.
method, nor do the functions `
regsub()`_ or `regsuball()`_
.
If ``backref`` is called without any prior call to ``match``
If ``backref`` is called without any prior call to ``match``
for this object in the same task scope, then an error message
for this object in the same task scope, then an error message
...
@@ -400,7 +410,7 @@ COPYRIGHT
...
@@ -400,7 +410,7 @@ COPYRIGHT
::
::
Copyright 2014-20
18
UPLEX Nils Goroll Systemoptimierung
Copyright 2014-20
23
UPLEX Nils Goroll Systemoptimierung
All rights reserved
All rights reserved
This document is licensed under the same conditions as the libvmod-re
This document is licensed under the same conditions as the libvmod-re
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment