Last month I discussed with some customers about configuring their 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 start with 34901 to 34909,
- North American Premium Numbers start with 1900, and
- Mexico's Premium Numbers start with 52900.
There are countries with way more complex breakdowns.
Building the Regular Expression with Negative Condition
If you are doing it 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:
false
true
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!