Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
Created December 19, 2018 03:20
Show Gist options
  • Save ambiorixg12/f7d8d1c382436a5322cfecbcbb0096df to your computer and use it in GitHub Desktop.
Save ambiorixg12/f7d8d1c382436a5322cfecbcbb0096df to your computer and use it in GitHub Desktop.
manipulation of ${EXTEN} variable
The ${EXTEN} variable properly has the syntax ${EXTEN:x:y}, where x is the starting position and y is the number of digits to return. Given the following dial string:
94169671111
we can extract the following digit strings using the ${EXTEN:x:y} construct:
${EXTEN:1:3} would contain 416
${EXTEN:4:7} would contain 9671111
${EXTEN:-4:4} would start four digits from the end and return four digits, giving us 1111
${EXTEN:2:-4} would start two digits in and exclude the last four digits, giving us 16967
${EXTEN:-6:-4} would start six digits from the end and exclude the last four digits, giving us 67
${EXTEN:1} would give us everything after the first digit, or 4169671111 (if the number of digits to return is left blank, it will return the entire remaining string)
This is a very powerful construct, but most of these variations are not very common in normal use. For the most part, you will be using ${EXTEN} (or perhaps ${EXTEN:1} if you need to strip off an external access code).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment