No matching results Documentation Forum
Asterisk Tutorial 12 - Asterisk Regular Expressions

Asterisk Tutorial 12 - Asterisk Regular Expressions


Asterisk Tutorial 12 - Asterisk Regular Expressions

Introducing Asterisk Phone Systems – Regular Asterisk Expressions (Regex)

Today, we expand our worldview!

Last time around we limited the world just one Softphone and on number (8888), but today we demonstrate how to make your Asterisk phone system dialplans a bit cleaner and more professional using Asterisk Expressions and dialplan Patterns.

If you are experienced with regular expressions from other programming languages, you will quickly realise that the expressions used are a specialised set for asterisk, which help you make clearer and easier to understand dialplan patterns.

To use Asterisk expressions, you will always need to write the expression starting with underscore:

_ 

This tells your dialplan that a placeholder is in place. In our example, we then used the most common expression X, which represents any number from 0 – 9.

In order to demonstrate how the X placeholder functions, we used the extension

_XXXX 

in our first example, which will dial any four digit number. However, should you as can be reasonably expected, need to dial shorter and longer phone numbers (so any number of any length) then a good starting point would be to use the full stop or dot expression.

.

Using this expression will allow you to repeat the previous expression as many times as required. Next we introduced a zero (0) to our placeholder, as many phone systems require users to dial a zero for the outside line. A common mistake is to use the

_0.

expression, as this will not work as the command is effectively saying you can dial as many zero’s as you like.

Another expression to avoid using (unless you really have to) is:

_. 

as this will match everything including special asterisk expressions (which we will cover later). Instead, we recommend using:

_X. 

or like in our demo:

_0X.

as this will select the outside line and allow users to call numbers of any length.

Just in case you didn’t spot it – Mathias made a mistake when explaining the expressions used by our friends over in the US. He was half right, just got the two a bit muddled up. Anyway, the asterisk expressions Z and N match numbers from 1 – 9 and 2 – 9 respectively.

For more on Asterisk Expressions, please visit www.VoIP-Info.org.

Next time, we will take our dialplans further using Asterisk Variables, where we demonstrate how to store information within the variables.

pascom hosted PBX - start upgrading your business communications today

Final Word

A well-configured business phone system that oozes useful tools, delivers excellent audio quality and intuitive call flows will leave callers with a highly professional impression. The configuration options and application availability and how well they are utilized will have a decisive impact on how professionally you manage your calls and therefore how your customers view your company. The switch to a pascom VoIP phone system solution provides the opportunity to not only upgrade your internal collaboration but also to redefine telephony in your company.

If you would like more information regarding pascom and our Asterisk based Software PBX, please visit our website or give the pascom team a call on +49 991 29691 0 to discuss your requirements and get started within minutes using our free hosted business VoIP phone system edition.