Question about dialplan patterns SOLVED

I want to use the SIP Header for my home phone for extensions 313 and 314. I want to use the SIP Header for my business line for all other extensions. None of the business extensions begin “31”.

So, I set up:

exten => _1NXXNXXXXXX/_31X,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip:...)
exten => _1NXXNXXXXXX/31X,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip:...)
exten => _1NXXNXXXXXX,1,SipAddHeader(P-ASSERTED-IDENTITY: "businessphone" <sip:...)

However, all calls are tagged with the businessphone CID. I tried the “" in my pattern, and also thought the "” to the left of the “/” might still rule, but neither syntax appears to work.

BTW, this works, but is inelegant:

exten => _1NXXNXXXXXX/313,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip:...)
exten => _1NXXNXXXXXX/314,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip:...)

I don’t believe patterns are supported after the /

Like I remember for me this kind of patterns were working fine _1NXXNXXXXXX/_31X.
Maybe you should move this pattern _1NXXNXXXXXX,1 on top.
I suppose it match any call.

OK, I got it working. Patterns are working after the /, but my ATA was not putting in the leading “1” like the smart phones (Polycom IP 321) were. So now,

exten => _1NXXNXXXXXX/_31X,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip: ...>)
exten => _NXXNXXXXXX/_31X,1,SipAddHeader(P-ASSERTED-IDENTITY: "homephone" <sip: ...>)
exten => _1NXXNXXXXXX,1,SipAddHeader(P-ASSERTED-IDENTITY: "businessphone" <sip: ...>)

It’s no shorter, but has two benefits: a) it’s elegant and b) it works! Now, to find the pattern that matches both 1NXXNXXXXXX and NXXNXXXXXX. It’s not obvious to me in the doc how to do that. I could do it easily with a regular expression, but I don’t think asterisk uses re for patterns.