# Remove "0" before numbers

**URL:** <https://community.asterisk.org/t/remove-0-before-numbers/76341>\
**Category:** Asterisk Support\
**Created:** [September 26, 2018, 1:27pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341 "2018-09-26T13:27:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![flubber](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@flubber](https://community.asterisk.org/u/flubber)\
**Post date:** [September 26, 2018, 1:27pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/1 "2018-09-26T13:27:46Z")

</div>

Hello can anyone share how and where to get 0+23123  
in which directory I need to log in to remove 0, and the numbers look like this: +23123

I call this number +23123 / of this number added to asterisk 123456789  
10x!!!

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 26, 2018, 1:58pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/2 "2018-09-26T13:58:23Z")

</div>

The directory and file depend on how you configured Asterisk. In the most common, plain, Asterisk installation, the file is /etc/asterisk/extensions.conf. Other files may be included from that, and the directory can be overridden, in the configuration. There are alternative ways of providing the dialplan, using different files.

I believe the sample configurations files, supplied with the Asterisk source code, include an example of stripping an initial digit when dialling a number.

If this relates to FreePBX, please use [https://community.freepbx.org/](https://community.freepbx.org/) instead.

---

<div class="post-metadata">

**Author:** ![flubber](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@flubber](https://community.asterisk.org/u/flubber)\
**Post date:** [September 26, 2018, 2:03pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/3 "2018-09-26T14:03:28Z")

</div>

> [@david551](#):
>
> The directory and file depend on how you configured Asterisk. In the most common, plain, Asterisk installation, the file is /etc/asterisk/extensions.conf. Other files may be included from that, and the directory can be overridden, in the configuration. There are alternative ways of providing the dialplan, using different files.
> 
> I believe the sample configurations files, supplied with the Asterisk source code, include an example of stripping an initial digit when dialling a number.

thanks for the reply,  
and what will be the removal code 0 before +123

extent =\> 0023123, 1 Goto (new,0${EXTENT:5}1), ?

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 26, 2018, 2:24pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/4 "2018-09-26T14:24:03Z")

</div>

That code replaces 00231 with 0. It does not add or remove “+” and will not match a number that contains “+”.

---

<div class="post-metadata">

**Author:** ![flubber](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@flubber](https://community.asterisk.org/u/flubber)\
**Post date:** [September 26, 2018, 2:28pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/5 "2018-09-26T14:28:35Z")

</div>

> [@david551](#):
>
> That code replaces 00231 with 0. It does not add or remove “+” and will not match a number that contains “+”.

but what is the code when 00123456789 calls 0023123 and does not display the dispatcher 0+123456789 and write +123456789?

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 26, 2018, 4:53pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/6 "2018-09-26T16:53:09Z")

</div>

You would need to do a pattern match that matches enough of the initial digits to recognize the general case, then takes a substring that excludes only the first, not the first five, digits.

---

<div class="post-metadata">

**Author:** ![flubber](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@flubber](https://community.asterisk.org/u/flubber)\
**Post date:** [September 26, 2018, 7:27pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/7 "2018-09-26T19:27:29Z")

</div>

how the code would look like?  
if you have any example code I will be very grateful to you…

10x

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [September 26, 2018, 8:10pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/8 "2018-09-26T20:10:20Z")

</div>

As I already said, there are examples supplied with Asterisk. The closest example actually strips 9, but that is easy to generalise.

You can’t expect people to show you, in detail, how to do basic things, as, otherwise, you will just keep coming back here, rather than learning how to do things for yourself.

---

<div class="post-metadata">

**Author:** ![johnkiniston](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/johnkiniston/32/28_2.png) [@johnkiniston](https://community.asterisk.org/u/johnkiniston)\
**Post date:** [September 26, 2018, 8:18pm UTC](https://community.asterisk.org/t/remove-0-before-numbers/76341/9 "2018-09-26T20:18:32Z")

</div>

The Wiki has some examples you can look at.

[https://wiki.asterisk.org/wiki/display/AST/Selecting+Characters+from+Variables](https://wiki.asterisk.org/wiki/display/AST/Selecting+Characters+from+Variables)

[https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching](https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching)

[https://wiki.asterisk.org/wiki/display/AST/Operators](https://wiki.asterisk.org/wiki/display/AST/Operators)

[https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function\_REGEX](https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_REGEX)
