# Greedy vs lazy quantifiers

`/<(.+?)>/`

**Match "<", then (one or more of any character, as few times as possible), then ">".**

## Step by step

- `<` — Match "<".
- `(.+?)` — Match (one or more of any character, as few times as possible).
- `>` — Match ">".

## Warnings

### Unanchored — matches anywhere in the input (caution)

Without ^ and $ the pattern succeeds if it matches ANY substring. A validator meant to check a whole value will therefore accept anything that merely contains a valid value: an email pattern without anchors accepts "nonsense a@b.co nonsense".

**Fix:** Wrap the pattern in ^ and $ if it is validating a whole string. Leave it unanchored only if you are genuinely searching within text.

### 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 [.].

## Details

- Capture groups: 1

---

Canonical URL: https://regex-explainer.gumballtools.com/regex/greedy-vs-lazy-quantifiers
JSON API: `GET https://regex-explainer.gumballtools.com/api/v1/explain?pattern=...`
MCP endpoint: `https://regex-explainer.gumballtools.com/api/mcp`
