Introducing Asterisk – Regular Asterisk Expressions
Today, we expand our world view!
Last time around we limited the world just one Softphone and on number (8888), but today we demonstrate how to make your dialplans a bit cleaner and more professional using Asterisk Expressions and Dialplan Patterns.
If you are used to 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 (_) which tells your Dialplan that a placholder 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 the . 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 _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 our demo _0X. which 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.
Visit our website for more information regarding pascom and our Asterisk based mobydick Software PBX. Alternatively, why not download our Community Version and try mobydick for yourself. For more general information about Asterisk, please visit their Website.
As always, let us know what you think or if you have any thoughts or Asterisk tips of your own, by leaving a comment either below or on our YouTube channel.
More Asterisk Tutorials:
- Introducing Asterisk – Outgoing Call Configuration
- Introducing Asterisk – Incoming Calls
- Introducing Asterisk – File Playback
- Introducing Asterisk – Dialplan Shortcuts
- Introducing Asterisk – First Dial
- Introducing Asterisk – Dial Plans
- Introducing Asterisk – SIP Peers
- Introducing Asterisk – Network Configurations
- Introducing Asterisk – Start Scripts
- Introducing Asterisk – Compiling Asterisk
- Introducing Asterisk