Fix colon expansion (bug #3572)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5023 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-02-13 20:57:52 +00:00
parent 9a43c29ca7
commit 2887217560
2 changed files with 57 additions and 21 deletions

View File

@@ -56,8 +56,8 @@ requires a variable), just write the name. To refer to the variable's value,
enclose it inside ${}. For example, SetVar takes as the first argument
(before the =) a variable name, so:
;exten => 1,2,SetVar(koko=lala)
;exten => 1,3,SetVar(${koko}=blabla)
exten => 1,2,SetVar(koko=lala)
exten => 1,3,SetVar(${koko}=blabla)
stores to the variable "koko" the value "lala" and to variable "lala" the
value "blabla".
@@ -65,6 +65,32 @@ value "blabla".
In fact, everything contained ${here} is just replaced with the value of
the variable "here".
_______________________________
REMOVING CHARACTERS FROM STRING
-------------------------------
If you want to remove the first N characters from a string, you just
add a colon and the number of characters, like
;Remove the first character of extension, save in "number" variable
exten => _9X.,1,setvar(number=${EXTEN:1})
A second colon limits the number of characters used from the original
string.
;Strip five characters from the start of string, use only two
; (character 6 and 7 in the original string)
exten => 1000,4,setvar(skrep=${STRING:5:2})
You can also count from the end of the string by giving a negative
position:
;Use the two first of the three last characters in the account code
exten => 4500,4,setvar(acc=${ACCOUNTCODE:-3:2})
Or
;Use the last three digits of the phone number
exten => 6112,4,goto(${EXTEN:-3},1)
___________________________
EXPRESSIONS:
---------------------------