This is the route that I'm using for testing this feature:
```
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");
}
}
```
This is the rules at dialplan:
```
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)|
```
As you can see if you use $(avp(s:pbx_cli)[*]) you will get "333
3, 2222, 1111". So the normal behavior for print but not what we want.
```
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
```
With the patch we are checking every value of the avp, one by one:
```
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]
```
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/18#issuecomment-72834432