Cut characters of a variable

Hi, I have a problem to cut data.
I have this variable:
extend => XX, n, Set (VARIABLE = $ {CDR (dstchannel)})

This value returns me:
“VARIABLE = SIP / 65-0000ce24”

How can I do to cut the value to 65 or SIP / 65.

Thank you
Regards.

cut with delimiter / taking the 2nd pattern.

cut with delimiter - taking the first pattern

Use the : notation as illustrated many times in the sample configuration file, assuming the position and length are fixed, otherwise use string functions, as already suggested. The : notation is much simpler, when it is applicable.

Thanks for the help, I did this:
extend => XX, n, Set (OPERATOR2 = $ {CUT (OPERATOR, /, 1-8)})

This returns me, the variable without value:
“OPERATOR2 =”

The idea is to cut SIP/ and with another cut leave the intern.
It’s wrong?

Thanks

It is possible that the bogus space is being interpreted as part of the function name.

I assume you are now setting OPERATOR rather than VARIABLE.

I solved my problem.
Create the following variables:

exten => XX,n,Set(OPERATOR_1=${CDR(dstchannel)})
exten => XX,n,Set(OPERATOR_2=${CUT(OPERATOR_1,,-1)})
exten => XX,n,Set(OPERATOR=${CUT(OPERATOR_2,/,2-)})

And return the following:

“OPERATOR_1=SIP/65-0000ce3d”) in new stack
“OPERATOR_2=SIP/65”) in new stack
“OPERATOR=65”) in new stack

Thank you very much for the help.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.