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

Cut() — Assigns part of one variable to another variable

Synopsis

    Cut(newvar=varname,delimiter,fieldspec)

Cuts an existing variable named varname into several pieces, and assigns one or more of the pieces to a new variable named newvar.

The delimiter argument is the character on which to cut varname. It defaults to -.

fieldspec is the number of the field you want to assign to newvar. Fields are counted starting with 1. The fieldspec may be specified as a range (with -) or a group of ranges and fields (with &). If more than one field is selected, Cut() leaves the delimiter between the fields.

Returns 0, or -1 on hangup or error.

    exten => 123,1,Set(TEST=123-456-7890)
    exten => 123,2,Cut(FIRST=TEST,-,2)        ; gives us 456
    exten => 123,3,Cut(SECOND=TEST,,1-2)      ; gives us 123-456
    exten => 123,4,Cut(THIRD=TEST,-,1&3)      ; gives us 123-7890

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