O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

SubString() — Saves substring digits in a given variable

Synopsis

    SubString(variable=string_of_digits,count1,count2)

Assigns the substring of string_of_digits to a given variable. The parameter count1 may be positive or negative. If it’s positive, we skip the first count1 digits from the left. If it’s negative, we move count1 digits from the end of the string to the left. The parameter count2 indicates how many digits to take from the point that count1 placed us. If count2 is negative, that many digits are omitted from the end.

This application is deprecated. Instead, use ${EXTEN: X : Y }.

    ; here are some examples using SubString():
    ;assign the area code (3 first digits) to variable TEST
    exten => 8885551212,1,SubString(TEST=8885551212,0,3)
    ; assign the last 7 digits to variable TEST
    exten => 8885551212,1,SubString(TEST=8885551212,-7,7)
    ; assign all but the last 4 digits to variable TEST
    exten => 8885551212,1,SubString(TEST=8885551212,0,-4)
    ;
    ; and here are the preferred alternatives:
    ;assign the area code (3 first digits) to variable TEST
    exten => 8885551212,1,Set(TEST=${EXTEN::3})
    ; assign the last 7 digits to variable TEST
    exten => 8885551212,1,Set(TEST=${EXTEN:-7:7})
    ; assign all but the last 4 digits to variable TEST
    exten => 8885551212,1,Set(TEST=${EXTEN:6}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required