tool::regex-guide
regex ip-address
/^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/
IPv4 Address Validation
Regex Pattern
/^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/Flags:
nonePattern Breakdown
^Start of string25[0-5]250–2552[0-4]\d200–2491\d{2}100–199[1-9]\d10–99\d0–9\.Literal dot separator{3}Three octet+dot groups$End of stringMatching Examples
✓
192.168.1.1✓
0.0.0.0✓
255.255.255.0✓
10.0.0.1Non-Matching Examples
✗
256.0.0.1✗
192.168.1✗
192.168.1.1.1✗
abc.def.ghi.jklAccurately validates IPv4 addresses by ensuring each octet falls within 0–255. Unlike a simple \d{1,3} pattern, this correctly rejects values like 256 or 999.
Language Usage
Common Use Cases
- ▸Validate IP addresses in server config files
- ▸Check firewall rule input
- ▸Extract IP addresses from log files
- ▸Validate input parameters for network scanners
- ▸Verify user-provided IPs against an allowlist
Related Patterns
ad · 300×250
// related tools