Regular Expressions 101

Quiz_7_Validate_An_IP

Open Workspace
  • PCRE2 (PHP)
  • Match
2

Regular Expression

/
^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|\d{2}|\d)(?:\.|$)){4}\b$
/
g

Description

Validate an IPv4 address. The addresses are four numbered separated by three dots, and can only have a maximum value of 255 in either octet. Start by trying to validate 172.16.254.1.

Submitted by Anonymous