# How to make long number shorter

Hi

My idea is…
…if incoming call recive then DID-Trunk separates SIP header. Thats ok and working…but what I need to do is that I want make number shorter only 3 last digits. Right now its 7 digits. Can anybody knows the simple solution to my problem…

Here is my extensions.conf

```[DID-Trunk] exten => s,1,Noop(Fixing DID using information from SIP TO header) exten => s,2,Set(BNUM=\${CUT(CUT(SIP_HEADER(To),@,1),+,2)}) ;exten => s,2,Set(BNUM=\${CUT(CUT(SIP_HEADER(To)|@|1)|:|2)},1) exten => s,3,Noop(\${BNUM}) exten => s,4,Set(CNUM=\${CUT(BNUM,2,2-)}) exten => s,5,Noop(\${CNUM}) exten => s,6,Goto(accounts,\${CNUM},1) ;;;;;;;;;;;;;;;;;;;; MAIN EXTENSIONS (PEERS) ;;;;;;;;;;;;;;;;;;;;; [accounts] exten => _44991XX,1,Dial(SIP/170,10) exten => _44991XX,2,Dial(SIP/171,20)```

With best wishes…
Andry

You’re going to want to use “Substr”

Taken from voip-info:

[code]Substrings
\${foo:offset:length}

returns a substring of the string foo, beginning at offset offset and returning the next length characters. The first character is at offset 0.

``````* If offset is negative, it is taken leftwards from the right hand end of the string.
* If length is omitted or is negative, then all the rest of the string beginning at offset is returned.
``````

Examples:

\${123456789:1} - returns the string 23456789
\${123456789:-4} - returns the string 6789
\${123456789:0:3} - returns the string 123
\${123456789:2:3} - returns the string 345
\${123456789:-4:3} - returns the string 678

Examples of use:

exten => _NXX.,1,SetVar(areacode=\${EXTEN:0:3}) - get the first 3 digits of \${EXTEN}
exten => _516XXXXXXX,1,Dial(\${EXTEN:3}) - get all but the first 3 digits of \${EXTEN}
exten => 100,1,SetVar(whichVowel=4)

exten => 100,2,SetVar(foo=AEIOU:\${whichVowel}:1) - sets \${foo} to the single letter ‘U’ [/code]

substr is overkill. The answer is on page 140 of Asterisk: The Future of Telephony

It might be. But that book is not an online resource I could point to.

It might be more helpful, if instead of pointing at a page on a book that some people might not have, you post a brief description of what is on that page. Otherwise we may as well write something like: “The answer is written on the back of this napkin on my desk.”

I’m not trying to start a flame war here, I’m just trying to highlight how that sort of comment may not be as constructive as you may have intended it to be.

It is: asteriskdocs.org/

Now that’s useful!

All I could conjure up was the index to that book

Thank you all…it was big help from all who posted replay…I get what I needed