Regex Example

IPv4 Pattern

Validates dotted IPv4 addresses.

Regex Pattern

^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$

Test Cases

  • 192.168.0.1 - match
  • 256.1.1.1 - no match
  • 10.0.0.254 - match

Edge Cases

  • Does not validate CIDR notation.
  • Leading zeros may be interpreted differently by some systems.