Need help with CUT function

Hello
I need some help with the CUT function.
I want to extract just 7 symbols before the ‘@’ symbol from the To: field.

It seems that this construction doesn’t work:

exten => s,1,Set(DN=${CUT(${SIP_HEADER(TO)},@,-7--1)})

For example, I want to extract 7654321 from something like *1237654321@domain.tld

Please advise.
Thanks!

If you CLI> show function CUT (or core show function CUT if 1.4), you’ll find that the first argument must be a variable name. I won’t comment on if this design makes CUT a better candidate for application or a function, but it is a requirement as of now.

thanks, missed this :frowning:

I’ve changed to this:

exten => s,1,Set(DN=${SIP_HEADER(TO)})
exten => s,2,Set(DN=${CUT(DN,@,-7)}) 

but still unable to cut just 7 symbols before @

what does “does not work” mean?

both lines of the code above are returning the same value like this

"DN=<sip:7654321@domain.tld>"

It seems I know the answer… The 3rd argument of the CUT command is a number of the substring before the delimiter, not a number of the symbol.

For now the following example does work:

exten => s,1,Set(DN=${SIP_HEADER(TO):5})
exten => s,2,Set(DN=${CUT(DN,@,1)})
exten => s,3,NoOp(Incoming call to ${DN})

Regular expression may be more suitable, but CUT should work.