How Asterisk picks a pattern
Line order in extensions.conf does not matter: Asterisk sorts patterns within a context itself. An exact match (112) always beats a pattern. Patterns are then compared character by character, and at each position the one with fewer possibilities wins. A digit is 1, N is 8 (2–9), Z is 9 (1–9), X is 10, [349] is 3. A trailing dot or "!" loses to everything. That is why _810X. beats _8XXXXXXXXXX: at the second position it has 1 option against 10.
Asterisk pattern characters
X— any digit 0–9;Z— 1–9;N— 2–9.[1-5],[349]— one digit from the set..— one or more of anything;!— zero or more, matches immediately.${EXTEN:1}— the number without its first digit,${EXTEN:-4}— the last 4 digits,${EXTEN:3:4}— 4 digits from the fourth.
FreeSWITCH
FreeSWITCH checks extensions in file order and matches the number against the regex in condition field="destination_number". Groups in the expression become $1, $2… in the bridge data. Anchor with ^ and $, or ^1\d{2} also matches 1001.
Related: SIP trunk generator, IVR builder, SIP log analyzer.