AdminGuide-Voss12-1.docx
119
B. Perl Regular Expression
In this section, the Perl Regular Expression which will be used for Dialplan will be
described.
■
Character class
Char
Description
Example
Example Description
[ ]
Character class
[0-9]
One digit number from 0 to 9
[^]
Negated character class
[^0-9]
A character excluding number.
■
Common character class
Char
Description
Example
Example Description
\d
One digit of decimal [0-9]
\d9
2 digits number ends with 9, such as 09, 59..
\D
One digit of character, not
decimal
\D9
2 digits character end with 9, such as A9, r9…
■
Alternation meta-character
Char
Description
Example
Example Description
|
‘or’ either left or right digit of |
(0|1|6)
One digit either 0, 1, or 6
■
Grouping meta-character
Char
Description
Example
Example Description
( )
A group, it is recognized as a
unit.
(01)(0|1|6)
Either 010, 011, or 016
■
Extracting meta-character
Extracting meta-character means that extract meta-character which matches by
using () and each value will be pointed with Matching variable such as $1, $2 …
Char
Description
Example
Example Description
$
Use the value which matches
with ( ) value.
(01)(2)
$1 has 01, $2 has 2
■
Matching Repetitions
Char
Description
Example
Example Description
?
Nothing or use the value once
(012)?
Nothing or 012 (used only once)
*
Nothing or use the value more
than twice.
(012)*
Nothing or 012, 012012, 012012012 ……
Difference between ? and * is that
+
Using more than once
(012)+
012 or 012012, 012012012 ……
x{n}
Use x multiplied by n
(012){2}
012012, use 012 twice
x{n,}
Use x at least n times
(012){2,}
012012012, 012012012012, ….
x{n,m}
Use min n time and man m
times.
(012){2,4}
012012012, more than twice, less than 4 times.
■
POSIX Character class