Dialplan regex help

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Dialplan regex help

OpenSIPS - Users mailing list
Hey guys,

I need your little help in regex, I have a regex that search the 9 Digits DID and append 972 as a prefix. So for example -

DID - 012345678
After regex - 9720123456789

But now I want to remove the first 0 by regex so that I should get the output like this - 97212345678

These are my current regex rules -
Matching Regular Expression -     ^0[0-9]{8}$
Substitution Regular Expression:   ^(0)([0-9]{8})$
Replacement Expression:            972\2

Any help or suggestions will be appreciated.
Thank you







_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dialplan regex help

Liviu Chircu

Hi Sharad,

Your solution seems correct to me, and should be working.  The only possible improvement
I see, purely cosmetical:

* match_exp: ^0[0-9]{8}$
* subst_exp:
^0([0-9]{8})$
* repl: 972\1

Does your current rule not work for you, or are you just asking for confirmation?

Best regards,

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 22.01.2020 20:50, Sharad Kumar via Users wrote:
Hey guys,

I need your little help in regex, I have a regex that search the 9 Digits DID and append 972 as a prefix. So for example -

DID - 012345678
After regex - 9720123456789

But now I want to remove the first 0 by regex so that I should get the output like this - 97212345678

These are my current regex rules -
Matching Regular Expression -     ^0[0-9]{8}$
Substitution Regular Expression:   ^(0)([0-9]{8})$
Replacement Expression:            972\2

Any help or suggestions will be appreciated.
Thank you







_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dialplan regex help

Tomi Hakkarainen
In reply to this post by OpenSIPS - Users mailing list

Hi,

The replacement should be \1 not \2.
At least in my tests on https://regexr.com with \2 the result is 9729 and with \1 its 972123456789

Matching Regular Expression -     ^0[0-9]{8}$
Substitution Regular Expression:   ^(0)([0-9]{8})$
Replacement Expression:            972\1

Tomi

On 22. Jan 2020, at 20.50, Sharad Kumar via Users <[hidden email]> wrote:

Hey guys,

I need your little help in regex, I have a regex that search the 9 Digits DID and append 972 as a prefix. So for example -

DID - 012345678
After regex - 9720123456789

But now I want to remove the first 0 by regex so that I should get the output like this - 97212345678

These are my current regex rules -
Matching Regular Expression -     ^0[0-9]{8}$
Substitution Regular Expression:   ^(0)([0-9]{8})$
Replacement Expression:            972\2

Any help or suggestions will be appreciated.
Thank you






_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Dialplan regex help

OpenSIPS - Users mailing list
In reply to this post by OpenSIPS - Users mailing list
Thank you guys. It's working now.


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users