Pattern matching question

I’ve been asked to set up dialing on a US-based asterisk server such that calls to numbers within the 440 area code can be dialed as seven digits, while calls to numbers outside the 440 area code can be dialed as ten digits.

For example a call to (440)222-3333 would be dialed as 2223333 while a call to (216)222-3333 would be dialed as 2162223333

I’m using a SIP provider that always requires outgoing calls be placed as 11 digits. So I set up the following context:

exten => _NXXXXXX,1,Dial(SIP/1440${EXTEN}@provider)
exten => _NXXNXXXXXX,1,Dial(SIP/1${EXTEN}@provider)

I’m concerned that things may not always works as intended since not having the 1 as the first digit of a non-local number may allow an unintended match on the 7-digit pattern. Can anyone comment?

you are fine because a pattern will always EXACTLY match that pattern, including the number of digits. but if you dial something that could match the LD pattern, it will wait to see if you are going to dial the extra digits.

you might also put in

exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN:1}@provider)

exten:1 will strip the first 1 digit…