0

IP Address Regex — Validate IPv4 with Ranges

Debug JavaScript regular expressions live: highlighted matches, capture groups, flags, and replacement preview.

Supports $1, $2 and named references like $<name>; $& inserts the whole match. Leave empty to hide the preview.

Processing... 0%

Result

This page opens with the classic strict IPv4 pattern: \b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b. Unlike the naive \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}, it validates every octet: 25[0-5] covers 250–255, 2[0-4]\d covers 200–249, 1\d\d covers 100–199, and [1-9]?\d handles 0–99.

The \b word boundaries on both ends matter more than they look: without them the pattern would happily match the 56.30.1.1 inside 256.300.1.1. The preloaded sample includes exactly such out-of-range addresses so you can verify that only real IPv4 addresses light up in the text.

This is the pattern to reach for when grepping access logs, filtering configuration files or validating input fields. Paste a chunk of your own logs into the test area — the match list below shows every address found together with its position, and the replacement mode lets you mask them, for example with a fixed placeholder.