Asterisk Dial Pattern Tester

Test Asterisk dial patterns against phone numbers. See which match, why, and which one wins.

How do I use this tool?

Paste your dial patterns in the left box (one per line) and test numbers in the right box. Click Test patterns to see results.

Each number gets a card showing whether it matched, which pattern character matched which digit, and (if multiple patterns match) which one Asterisk would pick based on specificity.

You can also paste a chunk of extensions.conf into the patterns box and click Extract from dialplan to pull out the exten => patterns automatically.

One pattern per line. You can also paste a chunk of extensions.conf and click Extract from dialplan to pull out the exten => patterns automatically.

One number per line. Paste from a CDR export, DID list, or just type a few test numbers.

Asterisk dial pattern syntax

Asterisk dial patterns start with an underscore (_) followed by a sequence of match characters. Without the underscore, the string is an exact literal match (like 911 or *72). The underscore tells Asterisk to treat the following characters as wildcards rather than literal digits.

CharacterMatchesExample
XAny digit 0 through 9_9XX matches 900 through 999
ZAny digit 1 through 9 (no zero)_ZXX matches 100 through 999
NAny digit 2 through 9 (no zero or one)_NXXXXXX matches 7-digit local numbers
[list]Any character in the set or range_[2-4]XX matches 200 through 499
.Wildcard: one or more of any character_011. matches any international number
!Wildcard: zero or more (returns immediately)_00! matches 00, 001, 0044, etc.

Character classes support ranges and individual characters: [1-5] matches 1 through 5, [147] matches 1, 4, or 7, and [2-49] matches 2, 3, 4, or 9. The . wildcard requires at least one character after it, while ! matches zero or more and causes Asterisk to stop waiting for additional digits.

Pattern specificity and matching priority

When a dialed number matches more than one pattern in the same context, Asterisk picks the most specific one. It compares patterns character by character from left to right. At each position, the more restrictive match type wins:

literal > [class] > N > Z > X > . > !

For example, _1NXXNXXXXXX beats _1XXXXXXXXXX for the number 18005551234, because N at position 2 is more specific than X. If two patterns tie at every position, the longer explicit match wins.

This is a common source of routing bugs. A broad pattern like _X. will match everything, but it loses to any more specific pattern. The problem shows up when you expect a number to hit one pattern and it hits another. This tool's color-coded breakdown makes those conflicts visible.

Common Asterisk dial patterns

PatternWhat it matches
_NXXNXXXXXX10-digit North American number (no leading 1)
_1NXXNXXXXXX11-digit NANP with leading 1
_011.International dialing (011 + country code + number)
_NXXXXXX7-digit local number
911Emergency services (exact match, no underscore needed)
_99119 + 911 for systems requiring 9 for an outside line
_*XXStar codes (*72 call forwarding, *73 cancel, etc.)
_XXX3-digit internal extensions (100 through 999)
_XXXX4-digit internal extensions (1000 through 9999)
_X.Catch-all (matches any dialed string of 2+ digits)

For a deeper explanation of how patterns fit into the Asterisk dialplan, see Asterisk Dial Patterns: The Complete Guide.

Found this useful? Buy me a coffee