[SR-Users] Using =~ to get the group identifier with longest match
David Villasmil
david.villasmil.work at gmail.com
Mon Jun 6 14:37:51 CEST 2011
Hello Iñaki,
I did this a long time ago using a db backend, i can't remember exactly how.
the table would be:
areacode, route
1 route1
13 route2
I connected to mysql and ran something like:
select * from routes where '$rU' like concat(areacode,'%') order by
len(areacode) desc limit 1;
that works perfectly
hope it helps
David
On Mon, Jun 6, 2011 at 10:25 AM, Iñaki Baz Castillo <ibc at aliax.net> wrote:
> Hi, I wonder how feasible is the folowing:
>
> I have a regular expresion like:
>
> REGEXP = "^((1|20)|(13|3|4)|(5|6))"
>
> There are 3 matching groups:
>
> 1) (1|20)
> 2) (13|3|4)
> 3) (5|6)
>
> I want to match the RURI user, let's suppose $rU = "138787686223". In
> this case the above regexp matches groups 1 and 2, but since group 2
> matching is longest ("13" is longest than "1") I want to get value 2.
>
> In case $rU = "999999" I need to get "null", in case $rU =
> "1000022323" I need to get "1".
>
> AFAIK there is no way to do it with current regular expression utils
> in Kamailio, but maybe I miss something. Thanks a lot.
>
>
> --
> Iñaki Baz Castillo
> <ibc at aliax.net>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20110606/0372780a/attachment.htm>
More information about the sr-users
mailing list