[SR-Users] Regular Expression Syntax

Daniel Tryba d.tryba at pocos.nl
Tue Mar 27 18:07:09 CEST 2018


On Tue, Mar 27, 2018 at 04:54:01PM +0100, Duarte Rocha wrote:
> I can make it work like that  /^[0-9]+/prefix$tU/ but this solution is far
> from perfect since i may not need the entire $tU.
> 
> I would like to use it like this  /^[0-9]+/prefix\1/ in order to not limit
> my regex to Kamailio only.  When i do it like this the regex result is only
> "prefix".
> 
> What's the correct syntax to add a prefix using the capture group ?

Kamailio is no different from any other regexp I ever used, an example
of how I normalize $fU (I'm not going to claim this the most efficient
example :)

$var(fU)=$fU;
$var(fU)=$(var(fU){re.subst,/^\+(.*)/00\1/});
$var(fU)=$(var(fU){re.subst,/^0([1-9].*)/0031\1/});
$var(fU)=$(var(fU){re.subst,/[^0-9]//});
$var(fU)=$(var(fU){re.subst,/^00(.*)/+\1/});




More information about the sr-users mailing list