What's :3:12 after CALLERID(num)

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#1
I want to add a prefix to a callerid number.
For exemple, I receive a 61122334455, and i want to display 061122334455
I think that the following code will be good, but what's information :3 and :12

I think that the ":3" is the pointer position number, but the next information ":12", what is it?


Code:
[from-trunk-custom]
exten => _X.,1,Set(CALLERID(num)=0${CALLERID(num):3:12})
exten => _X.,n,Goto(from-trunk,${EXTEN},1)
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#2
From the page at http://www.voip-info.org/wiki-Asterisk+variables

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:

Code:
    ${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:

Code:
    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'
Does that explain it?
 

danardf

Joined
Dec 3, 2007
Messages
8,069
Likes
10
Points
88
#3
Ha Ok... Thanks a lot. :)

Like that, it's more clear.
The first information it was ok, but for the second information now, I know that I can get some digits (10 or more digits from offset).

Very cool wiseoldowl ;)
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,567
Latest member
achilont13
Top