Greetings,
I'm having some trouble with the syntax used in the {re.subst,expression} method. What i want to do is add a prefix to a capture group.
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 ?
Thanks in advance
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/});