Network & Web · In-Browser Regular Expression Lab
IPv4 Regex — Validate 0-255 Decimal Octets with CIDR Support
Strictly validates IPv4 addresses ensuring each octet is within the valid 0 to 255 numerical range.
Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:192.168.1.1
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
192.168.1.1 Pass
10.0.0.254 Pass
127.0.0.1 Pass
255.255.255.0 Pass
Expected Invalid Samples (Must Reject)
256.1.1.1 Rejected (Pass)
192.168.1 Rejected (Pass)
192.168.1.1.1 Rejected (Pass)
1.2.3.999 Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^(?:(?: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]?)$/;
const text = "192.168.1.1";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Checks four dot-separated octets ensuring numbers never exceed 255. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| 25[0-5] | Range 250-255 | Matches 250 to 255. |
| 2[0-4][0-9] | Range 200-249 | Matches 200 to 249. |
| [01]?[0-9][0-9]? | Range 0-199 | Matches 0 to 199. |
| \. | Dot delimiter | Matches period separating octets. |
| {3} | Repeat 3 times | Repeats octet and dot for the first 3 groups. |
Frequently Asked Questions
How to add CIDR subnet support?
Related Regular Expressions
Browse All 40 PatternsNetwork & Web
IPv6 Address Validator
Matches standard 8-group IPv6 addresses as well as compressed double-colon (::) formats.
/^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^::1$|^::$/iTest regex
Network & Web
MAC Address Matcher
Matches 6-byte IEEE 802 Media Access Control (MAC) hardware addresses with colons or hyphens.
/^(?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2})$/Test regex
Network & Web
Domain Name Matcher
Validates Fully Qualified Domain Names (FQDN) adhering to DNS hostname specification (RFC 1035).
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/Test regex