# Why an unescaped dot matches too much

`/^example.com$/`

**Match a whole string consisting of "e", then "x", then "a", then "m", then "p", then "l", then "e", then any character, then "c", then "o", then "m".**

## Step by step

- `^` — Anchor to the start of the input.
- `e` — Match "e".
- `x` — Match "x".
- `a` — Match "a".
- `m` — Match "m".
- `p` — Match "p".
- `l` — Match "l".
- `e` — Match "e".
- `.` — Match any character.
- `c` — Match "c".
- `o` — Match "o".
- `m` — Match "m".
- `$` — Anchor to the end of the input.

## Warnings

### Unescaped dot matches any character (caution)

A dot among literal characters matches ANY character, not a period. So a pattern written for "1.2" also matches "1x2", and one written for "example.com" matches "exampleXcom".

**Fix:** Escape intended periods as \. — or use a character class [.].

### 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/unescaped-dot-in-regex
JSON API: `GET https://regex-explainer.gumballtools.com/api/v1/explain?pattern=...`
MCP endpoint: `https://regex-explainer.gumballtools.com/api/mcp`
