DID in quotes (To: Field)

Hello all,

I get from my provider the DID in quotes. How can I evaluate them?

sip header:
To: “9999DID9999” sip:101@sip.provider.de

Where 9999DID9999 is the line being called (DID) and 101 is the extension number on the provider’s pbx system.

What I need is the part in quotes as DID so Asterisk can handle it.

Thanks a lot in advance.



The following extracts it from the To URI user part, which is a more common situation, but should show most of the general principles:

1 Like

Dear david,

thank you. maybe i’m too stupid for this (or it’s just too late today), but i need the part which is just in quotes before the sip:2125551212@

To: “9999DID9999” sip:101@sip.provider.de

tried exten => _.,n(PJSIP),Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,To),“,1),”,2)},1) to get the part in Quotes, but without success.

You’d need to quote the ". I assume \ will work, but the way Asterisk handles quotes is a bit funny, so one might have to experiment.

You could also try regular expressions.

Please mark up code as pre-formatted text, e.g.


To: “9999DID9999” sip:101@sip.provider.de

The last line was invalid even in the raw version, although you did have it correct in the raw version of your first post.

To: "9999DID9999" <sip:101@sip.provider.de>

tried exten => _.,n(PJSIP),Goto(from-pstn,${CUT(CUT(PJSIP_HEADER(read,To),",1),",2)},1) to get the part in Quotes, but without success.

Note, whilst I would hope the FreePBX people would have found and fixed it if that example were wrong, I would have used ${} around the nested CUT.

I got it working now, but I am not sure why :wink:

exten => _.,n,Set(CALLERID(dnid)=${CUT(CUT(PJSIP_HEADER(read,To),@,1),\",2)})

Let’s start again from the beginning.

The provider transmits the following information in the To Field

To: “1234567890” sip:101@sip.provider.de

Where 1234567890 is the phone number of the trunk line (the number dialed from the caller). And 101 is the extension that is defined in my provider’s pbx for the sip account that the asterisk/freePBX uses to register there.

In the CUT command above, I replaced the : with a \", after which it now seems to work without any problems.

I would prefer a regular expression to be on the safe side, but unfortunately I have no idea about that.

Suggestions are always welcome.

anyone any idea?

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