SubString( )
|
Saves substring digits in a given variable
|
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}
|