Regular expressions (regex) provide a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A detailed tutorial on regular expressions is beyond the scope of this section. It provides only a useful mnemonic for regex within VWcms. Regular expressions can be used in conditional configuration matching, as well as in the VWcms search facility. Just prefix the expression with a ^ character.
| Description |
|
Usage |
| match-self operator |
|
ordinary characters, e.g. a b c A B C 1 2 3
|
match-any-character operator
|
|
. (period)
|
concatenation operator
|
|
juxtaposition
|
repetition operators
|
|
* + ? {}
|
alternation operators
|
|
|
|
list operators
|
|
[...] [^...]
|
grouping operators
|
|
(...)
|
back-reference operator
|
|
\digit
|
anchoring operators
|
|
^ $
|
backslash operator
|
|
escape a meta-character, e.g. \ ^ . $ | [ (
|
The following operators are used to match one, or in conjunction with the repetition operators more, characters of the target string. These single and leading characters are reserved meta-characters and must be escaped using a leading backslash ("\") if required as a literal character in the matching pattern.
| Expression |
|
Purpose |
^
|
|
match the beginning of a line
|
. (period)
|
|
match any character
|
$
|
|
match the end of a line
|
|
|
|
alternation (logical or)
|
[abc]
|
|
match only a, b or c
|
l[^abc]
|
|
match anything except a, b c
|
[a-z0-9]
|
|
match any character in the range a to z or 0 to 9
|
Repetition operators control the extent, or number, of whatever the matching operators match. These are also reserved meta-characters and must be escaped using a leading backslash if required as a literal character.
| Expression |
|
Function |
*
|
|
match 0 or more times
|
+
|
|
match 1 or more times
|
?
|
|
match 0 or 1 time
|
{n}
|
|
match exactly n times
|
{n,}
|
|
match at least n times
|
{n,m}
|
|
match at least n but not more than m times
|
Examples
| ^\.example\.net|example\.net |
|
matches any host name containing the domain example.net
|
/one/.*|/two/.*
|
|
matches paths beginning with /one/ or with /two/
|
/[0-9]/.*
|
|
matches numeric paths (bit contrived)
|
![print this and sub-pages [PRINT]](/_vdub/print_plus.png)