# Why [A-z] is almost never what you want

`/^[A-z]+$/`

**Match a whole string consisting of one or more of "A" to "z".**

## Step by step

- `^` — Anchor to the start of the input.
- `[A-z]+` — Match one or more of "A" to "z".
- `$` — Anchor to the end of the input.

## Warnings

### Character range spans more than it looks like (caution)

`A-z` covers punctuation as well as letters, because ranges follow character codes rather than the alphabet. [A-z] for example also matches [ \ ] ^ _ and `.

**Fix:** Write the ranges you mean explicitly: [A-Za-z].

### Anchors match string ends, not line ends (info)

Without the m flag, ^ and $ match only the very start and end of the input — not the start and end of each line. On multi-line input this is often not what was intended.

**Fix:** Add the m flag if the pattern should apply per line.

## Details

- Capture groups: none

---

Canonical URL: https://regex-explainer.gumballtools.com/regex/a-to-z-character-range
JSON API: `GET https://regex-explainer.gumballtools.com/api/v1/explain?pattern=...`
MCP endpoint: `https://regex-explainer.gumballtools.com/api/mcp`
