Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
(?:\d{1,3}\.){3}\d{1,3}\b|\b(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}\b|\b(?:[A-Fa-f0-9]{1,4}:){0,6}(?:[A-Fa-f0-9]{1,4})?::(?:[A-Fa-f0-9]{1,4}:){0,5}(?:[A-Fa-f0-9]{1,4})?
/
gm

Description

Regex pattern detection for IPv4 addresses and IPv6 addresses in zero compression format.

Submitted by Lewis Wigmore - 10 months ago (Last modified 10 months ago)