100% Client-Side β’ 0 B Data Leaves Browser
security
IPv4 Address Validation Regex
Validates standard dotted decimal IPv4 network address within range 0.0.0.0 to 255.255.255.255.
Regular Expression 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]?)$/
Valid Match Example:
192.168.1.1
Invalid / Non-Match Example:
999.12.34.56
Regex Syntax Breakdown & Explanation
- β’25[0-5] : Matches numbers 250-255
- β’2[0-4][0-9] : Matches numbers 200-249
- β’[01]?[0-9][0-9]? : Matches numbers 0-199
- β’\. : Period delimiter repeated 3 times
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^(?:(?: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 isValid = regex.test("192.168.1.1");
console.log(isValid); // truePython (re)
import re
pattern = r"^(?:(?: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]?)$"
match = re.match(pattern, "192.168.1.1")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^(?:(?: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]?)$`)
fmt.Println(re.MatchString("192.168.1.1"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^(?:(?: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]?)$/. Validates standard dotted decimal IPv4 network address within range 0.0.0.0 to 255.255.255.255.