Regular expressions
The FreeSWITCH XML Dialplan makes extensive use of Perl-compatible regular expressions (PCRE). A regular expression is a means of executing a true/false test on a string of characters. This is commonly called pattern matching. When a regular expression is applied to a string of characters, we answer a simple question: does it match the pattern? If the answer is yes, then usually it means that a particular condition is met, and therefore, the extension in question can be executed. In some cases, we want to do something if a pattern is not met (see the Actions and anti-actions section of this chapter.)
Perl-compatible regular expressions follow a very specific syntax. It can be overwhelming at first. However, once you learn the basics you will appreciate just how powerful they are. The following are some sample regular expressions and their meanings:
Pattern |
Meaning |
---|---|
123 |
Match any string containing the sequence "123" |
^123 |
Match any string beginning with the sequence... |