[SR-Users] Using =~ to get the group identifier with longest match

Daniel-Constantin Mierla miconda at gmail.com
Mon Jun 6 10:32:26 CEST 2011


Hello,

On 6/6/11 10:25 AM, Iñaki Baz Castillo 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.
one option that comes in my mind is to break it in several if 
conditions, matching one group at a time, written in the order of 
preferences.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list