You almost never need to write regex by hand — the Destination Builder generates them for you. This guide is for when the case calls for it.
The essentials in 60 seconds
| Symbol | Means | Example |
|---|---|---|
^ | starts with | ^57 → anything starting with 57 |
$ | ends there | ^573[0-9]{9}$ → exact Colombian mobile |
[0-9] | one digit | [3-5] → a 3, 4 or 5 |
{n} | n repetitions | [0-9]{7} → seven digits |
| | or | ^(3097|3098) |
. | any character | avoid it: prefer [0-9] |
Ready-made recipes
| I want to match… | Pattern |
|---|---|
| All of Colombia | ^57 |
| Colombian mobiles only (57 + 3 + 9 digits) | ^573[0-9]{9}$ |
| Spain landline (34 + 8/9 + 8 digits) | ^34[89][0-9]{8}$ |
| Mexico (52, 12 or 13 total digits) | ^52[0-9]{10,11}$ |
| Several specific prefixes | ^57(300|301|302) |
| US/Canada (NANP) | ^1[2-9][0-9]{9}$ |
Numbers in NEXIA travel as E.164 without “+”: country + number, digits
only (
573001234567). Write your patterns against that format.Tech prefix and digits
Technical manipulation of the number lives in the termination point, not in the dial peer's regex: there you define the tech prefix your carrier requires you to prepend and the digit strip if applicable. The dial peer decides where; the termination point decides how it is handed to the carrier.
Always test
After writing a pattern: Test a Number with 3 numbers — one that should match, one that should not, and an edge one (min/max length). Two minutes that keep you from routing a whole country through the wrong carrier.