Regular Expressions 101

Validate an IP

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

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

Description

52 character long regex to validate IP address.

Submitted by Karthik