<p>This is the route that I'm using for testing this feature:</p>

<pre><code>route[TEST] {
    pv_unset("$(avp(s:pbx_cli)[*])");
    $avp(s:pbx_cli) = "1111";
    $avp(s:pbx_cli) = "2222";
    $avp(s:pbx_cli) = "3333";
    $var(num) = "11118765";
    if(dp_translate("2", "$var(num)/$avp(s:dest)"))
    {
        xlog("$var(num) translated to var $avp(s:dest) \n");
    }
    $var(num) = "0022228765";
    if(dp_translate("2", "$var(num)/$avp(s:dest)"))
    {
        xlog("$var(num) translated to var $avp(s:dest) \n");
    }
    $var(num) = "00333387";
    $(avp(s:cloud_pbx_cli)[*]) = "666";
    if(dp_translate("2", "$var(num)/$avp(s:dest)"))
    {
        xlog("$var(num) translated to var $avp(s:dest) \n");
    }
    if(dp_translate("1", "$var(num)/$avp(s:dest)"))
    {
        xlog("$var(num) translated to var $avp(s:dest) \n");
    }
}
</code></pre>

<p>This is the rules at dialplan:</p>

<pre><code>sqlite> select * from dialplan;
1|1|1|2|^(00|\+)([1-9][0-9]+)$|0|^(00|\+)([1-9][0-9]+)$|\2|
2|2|1|2|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|0|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|\1|
3|1|2|0|^(00|\+)([1-9][0-9]+)$|0|^(00|\+)([1-9][0-9]+)$|\2|
4|2|2|0|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|0|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|\1|
5|1|2|1|^(00|\+)([1-9][0-9]+)$|0|^(00|\+)([1-9][0-9]+)$|\2|
6|2|2|1|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|0|^$avp(s:caller_cc)$avp(s:caller_ac)([1-9][0-9]+)$|\1|
7|2|2|1|^(00|\+)?$(avp(s:pbx_cli)[*])([0-9]{3})$|0|^(00|\+)?$(avp(s:pbx_cli)[*])([0-9]{3})$|\2|
8|2|2|1|^(00|\+)?$(avp(s:pbx_cli)[*])([1-9]{2})$|0|^(00|\+)?$(avp(s:pbx_cli)[*])([1-9]{2})$|$avp(s:cloud_pbx_cli)|
</code></pre>

<p>As you can see if you use $(avp(s:pbx_cli)[*]) you will get "333<br>
3, 2222, 1111". So the normal behavior for print but not what we want. </p>

<pre><code> 4(1425) DEBUG: dialplan [dp_repl.c:77]: dpl_dynamic_pcre(): compiled dynamic pcre expression: ^(00|\+)?$(avp(s:pbx_cli)[*])([0-9]{3})$$ (^(00|\+)?333
3, 2222, 1111([0-9]{3})$) 2

</code></pre>

<p>With the patch we are checking every value of the avp, one by one:</p>

<pre><code> 4(5674) DEBUG: dialplan [dp_repl.c:249]: dpl_dynamic_pcre_list(): parsed pcre expression: ^(00|\+)?$(avp(s:pbx_cli)[*])([0-9]{3})$$
 4(5674) DEBUG: dialplan [dp_repl.c:222]: dpl_dyn_pcre_comp(): compiled dynamic pcre expression: ^(00|\+)?3333([0-9]{3})$ 2
 4(5674) DEBUG: dialplan [dp_repl.c:222]: dpl_dyn_pcre_comp(): compiled dynamic pcre expression: ^(00|\+)?2222([0-9]{3})$ 2
 4(5674) DEBUG: dialplan [dp_repl.c:222]: dpl_dyn_pcre_comp(): compiled dynamic pcre expression: ^(00|\+)?1111([0-9]{3})$ 2
 4(5674) DEBUG: dialplan [dp_repl.c:628]: translate(): match check: [^(00|\+)?1111([0-9]{3})$] -1
 4(5674) DEBUG: dialplan [dp_repl.c:628]: translate(): match check: [^(00|\+)?2222([0-9]{3})$] -1
 4(5674) DEBUG: dialplan [dp_repl.c:628]: translate(): match check: [^(00|\+)?3333([0-9]{3})$] -1
 4(5674) DEBUG: dialplan [dp_repl.c:613]: translate(): regex operator testing over [00333387]
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/pull/18#issuecomment-72834432">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36Zba4YrLp0jJMSf9N57EfJchGlTbLks5noe_EgaJpZM4DOX5A.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/kamailio/kamailio/pull/18#issuecomment-72834432"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>