User Rating: 5 / 5

Star Active Star Active Star Active Star Active Star Active

Last month I have been discussing with some customers about configuring its PBX. They want to allow all the traffic in their country but premium numbers. Premium numbers are those that the caller is billed when a call is done. In short, those are the 1-900 in North America. If your VoIP company doesn't have a way to secure the payment from a customer where a premium call is done, it may be a good idea to block them; premium rates are quite high.

In the case of North America, it is quite easy, maybe it is easier if you do a regular expression such as /^\+?1?900\d{6}$/ which will block all the premium numbers. However, if you do not live here or you want to block more things or your country doesn't have an easy breakdown, this could be a difficult task.

Fortunately for everybody, FreeSWITCH supports PCRE regular expressions and PCRE-regular expressions have a way to specify negative conditions.

Find What You Want to Forbid

The first step is to find what you want to forbid. This request was to forbid all premium numbers so I quickly researched (for the sake of this document I won't put a long list).

  • Spain's Premium Numbers are 34901 to 34909
  • North Americans Premium Numbers are 1900
  • Mexico's Premium Numbers are 52900

There are countries with way more complex breakdowns.

Building the Regular Expression with Negative Condition

If you are doing by country, you can use these:

  • For Spain ^34(?!(90[1-9]))
  • For North America ^1(?!(900))
  • For Mexico ^52(?!(900))

Want to do a test, look:

This email address is being protected from spambots. You need JavaScript enabled to view it.> regex 34904123456|^34(?!(90[1-9]))
This email address is being protected from spambots. You need JavaScript enabled to view it.> regex 34900123456|^34(?!(90[1-9]))

Easy right? Pay attention to the ?! operator that indicates that everything will pass but those numbers. You can also concatenate everything in a single expression. That's your homework. European people may want to allow any call that goes to Europe (fixed and mobile) but premium numbers, this is one case where the negative conditions become very useful.

Good luck!

blog comments powered by Disqus


Read about IT, Migration, Business, Money, Marketing and other subjects.

Some subjects: FusionPBX, FreeSWITCH, Linux, Security, Canada, Cryptocurrency, Trading.