Hi all
Maybe a very simple question - but I cannot see the solution - I am more or less newbie ;)
I need to do some string operations in kamailio.cfg. How can I get the cli from the following string: sip:+41523940347@195.216.67.103;user=phone
I only would need +41523940347 in a variable
Something like
$avp(s:myCli) = ^sip:+(\d{11})@.{1,40}$
Any idea?
Thanks in advance Oli
Oliver Roth writes:
I need to do some string operations in kamailio.cfg. How can I get the cli from the following string: sip:+41523940347@195.216.67.103;user=phone
I only would need +41523940347 in a variable
Something like
$avp(s:myCli) = ^sip:+(\d{11})@.{1,40}$
Any idea?
see if any of these would help:
http://www.kamailio.org/wiki/cookbooks/devel/transformations#uri_transformat...
-- juha
Got it - thanks for your help.
$avp(s:fromCLI) = $(ai{re.subst,/^sip:(.*)@(.*)/\1/});
-----Ursprüngliche Nachricht----- Von: sr-users-bounces@lists.sip-router.org [mailto:sr-users-bounces@lists.sip-router.org] Im Auftrag von Juha Heinanen Gesendet: Sonntag, 3. November 2013 21:58 An: Kamailio (SER) - Users Mailing List Cc: kamailio@AaronLux.com Betreff: [SR-Users] Regex question
Oliver Roth writes:
I need to do some string operations in kamailio.cfg. How can I get the cli from the following string: sip:+41523940347@195.216.67.103;user=phone
I only would need +41523940347 in a variable
Something like
$avp(s:myCli) = ^sip:+(\d{11})@.{1,40}$
Any idea?
see if any of these would help:
http://www.kamailio.org/wiki/cookbooks/devel/transformations#uri_transformat...
-- juha
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
----- E-Mail ist virenfrei. Von AVG überprüft - www.avg.de Version: 2014.0.4158 / Virendatenbank: 3615/6804 - Ausgabedatum: 02.11.2013
On 11/3/13 10:07 PM, Oliver Roth wrote:
Got it - thanks for your help.
$avp(s:fromCLI) = $(ai{re.subst,/^sip:(.*)@(.*)/\1/});
This gets what you need if there are no parameters to username part of the URI. Juha tried to suggest to use the uri transformation that uses an URI parser internally and returns parts of it as you need. It should be like:
$(ai{uri.user})
See the link from Juha for more details about uri transformations.
Cheers, Daniel
-----Ursprüngliche Nachricht----- Von: sr-users-bounces@lists.sip-router.org [mailto:sr-users-bounces@lists.sip-router.org] Im Auftrag von Juha Heinanen Gesendet: Sonntag, 3. November 2013 21:58 An: Kamailio (SER) - Users Mailing List Cc: kamailio@AaronLux.com Betreff: [SR-Users] Regex question
Oliver Roth writes:
I need to do some string operations in kamailio.cfg. How can I get the cli from the following string: sip:+41523940347@195.216.67.103;user=phone
I only would need +41523940347 in a variable
Something like
$avp(s:myCli) = ^sip:+(\d{11})@.{1,40}$
Any idea?
see if any of these would help:
http://www.kamailio.org/wiki/cookbooks/devel/transformations#uri_transformat...
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
E-Mail ist virenfrei. Von AVG überprüft - www.avg.de Version: 2014.0.4158 / Virendatenbank: 3615/6804 - Ausgabedatum: 02.11.2013
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 03 Nov 2013, at 20:31, Oliver Roth oliver.roth@triotel.ch wrote:
Hi all
Maybe a very simple question - but I cannot see the solution - I am more or less newbie ;)
I need to do some string operations in kamailio.cfg. How can I get the cli from the following string: sip:+41523940347@195.216.67.103;user=phone
I only would need +41523940347 in a variable
Something like
$avp(s:myCli) = ^sip:+(\d{11})@.{1,40}$
Any idea?
The pseudovariables are there as shortcuts. You want the $rU. http://www.kamailio.org/wiki/cookbooks/4.0.x/pseudovariables
Then use a transformation or a regexp to cut of the + sign. s.strip seems to do what you need.
http://www.kamailio.org/wiki/cookbooks/4.0.x/transformations
Cheers, /O