Verified 2026-09-18

IPv4 Address

Matches valid dotted-decimal IPv4 addresses such as 192.168.1.1.

Use word boundaries so the pattern finds addresses inside longer text without matching fragments of bigger numbers.

regexnetworkvalidation

Find

\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b

The octet branches are order-sensitive: 25[0-5] and 2[0-4][0-9] must come before the permissive 0-199 branch, otherwise 25 matches first and truncates 250.

Common mistakes

  • Dropping the word boundaries, which lets the pattern match inside strings like 999.1.1.1.
  • Assuming every regex flavor treats \b identically between digits and dots.

Related

Permalink: https://merginit.com/reference/regex/ipv4-address