I have an old version of freePBX (over 5000 extensions, hundreds of IVRs) that I must document for migration to newer version. I must map what IVRs use which trunks. To do this, I must match the number being dialed to the dial pattern of the outbound route.
The 'extensions' column of the table with patterns I must match looks like
19328555
_13XXXX
_1933370[0-2]
_2805XX
_28[3-7]XXX
_331XXX
_848XXX
_85XXXXX
_879XXX
For example I must find which 'extensions' pattern matches the number 8481234 then I can grab the trunk from another column.
I know there must be a function embedded in Asterisk that works like
$number='8481234';
$pattern='_879XXX';
if (asterisk_pattern_match($number,$pattern)) {
#get trunk column from that row
}
It could be SQL, or Perl or PHP. I could write it, but I'm sure I would be reinventing the wheel. Does anyone have or know where a function like this may be? I have googled every way I can think of, but all the results are about using MySQL within the asterisk dial plan, and that is of no value to me.
Thanks!