Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

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

Description

This regex matches every IPv4 address with or without 0s before every number.

For example: 192.168.1.1 00000000000192.168.00000000000001.01

Submitted by anonymous - 4 years ago