[OpenSIPS-Users] re.subst usage

Ben Newlin Ben.Newlin at genesys.com
Wed Jul 29 13:25:58 EST 2020


Also, if you know the length of the prefix you could just s.substr.

https://www.opensips.org/Documentation/Script-Tran-3-1#s.substr


Ben Newlin

From: Users <users-bounces at lists.opensips.org> on behalf of Liviu Chircu <liviu at opensips.org>
Reply-To: OpenSIPS users mailling list <users at lists.opensips.org>
Date: Wednesday, July 29, 2020 at 9:15 AM
To: OpenSIPS users mailling list <users at lists.opensips.org>
Subject: Re: [OpenSIPS-Users] re.subst usage

On 29.07.2020 15:44, Barnaby Ritchley wrote:
With $rU of 12345441234567890 we would expect $var(to_user) to be 441234567890 (stripping off the first 5 digits) however $var(to_user) returns 12345441234567890

What am I doing wrong?


Hey Barnaby,

I would guess that the PCRE library does not support the "\d" literal, which also seems to be confirmed by this site [1].  The "/\+?[0-9]{5}([1-9][0-9]+)/\1/g" regexp should remove your tech prefix as expected.

BR,

[1]: https://www.regular-expressions.info/shorthand.html<https://www.regular-expressions.info/shorthand.html>

--

Liviu Chircu

www.twitter.com/liviuchircu<http://www.twitter.com/liviuchircu> | www.opensips-solutions.com<http://www.opensips-solutions.com>



OpenSIPS Summit 2020 Distributed

  www.opensips.org/events/Summit-2020Distributed<http://www.opensips.org/events/Summit-2020Distributed>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200729/9e83f90f/attachment.html>


More information about the Users mailing list