# DID Pattern and Caller ID Pattern

When you set up DID (Direct Inward Dialing, a phone number that routes callers straight to a specific destination on your system) numbers or Caller IDs in Cloud Voice, you can enter a **Pattern** instead of a single fixed number. A pattern uses special characters to describe a whole group of numbers at once, so one entry can match many callers or dialed numbers. This page explains each character you can use and shows how sample patterns behave.

## The Pattern field

A **Pattern** field is shown wherever you configure DID numbers or Caller IDs. In it you can type a complete number, or combine the special characters below to match a range of numbers rather than an exact one.

| Character | What it matches |
|-----------|-----------------|
| `X` | Any single digit, `0` through `9`. |
| `Z` | Any single digit, `1` through `9`. |
| `N` | Any single digit, `2` through `9`. |
| `[###]` | Any one of the digits listed inside the brackets. For example, `[123]` matches `1`, `2`, or `3`. |
| `.` | One or more trailing digits. For example, `9011.` matches any number that begins with `9011` but is longer than `9011` itself. |
| `!` | Zero or more trailing characters. For example, `9011!` matches any number that begins with `9011`, including `9011` on its own. |

:::note
Inside brackets you can express a run of consecutive digits with a dash. For example, `[136-8]` matches `1`, `3`, `6`, `7`, or `8`.
:::

:::caution
`.` and `!` look similar but differ at the boundary. `9011.` needs at least one extra digit after `9011`, so `9011` by itself will not match. `9011!` matches `9011` on its own as well. Choose the wrong one and a number you expected to route can be silently rejected, so confirm which behavior you need before you save.
:::

## Pattern examples

The following patterns show which numbers each one accepts and which it rejects.

| Pattern | Matches | Does not match |
|---------|---------|----------------|
| `0591.` | `05910`, `0591012345` | `0591`, `0592229929` |
| `+[13-5]XZN!` | `+4022`, `+1136282882` | `+0136282882`, `+1106282882` |
| `0591ZXXXX` | `059123456`, `059133456` | `05912345`, `059103456` |

:::tip
Read a compound pattern one character at a time. Take `0591ZXXXX`: the `0591` is literal and must appear exactly, `Z` matches one digit from `1` to `9`, and each `X` matches one digit from `0` to `9`, so the whole pattern accepts a 9-digit number in the form `0591` + a non-zero digit + four more digits. That is why `05912345` fails (only 8 digits, one `X` short) and `059103456` fails (the digit in the `Z` position is `0`, which `Z` never matches).
:::
