Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(([0-9A-Fa-f]{1,4}:){7})([0-9A-Fa-f]{1,4})$|(([0-9A-Fa-f]{1,4}:){1,6}:)(([0-9A-Fa-f]{1,4}:){0,4})([0-9A-Fa-f]{1,4})$
/
gm

Description

Matches all IPv6 Addresses (without Port) fe80::21d8:f50:c295:c4be 2001:cdba:0000:0000:0000:0000:3257:9652 2001:cdba:0:0:0:0:3257:9652 2001:cdba::3257:9652 2001:cdba::1222 21DA:D3:0:2F3B:2AA:FF:FE28:9C5A 2001:cdba::1:2:3:3257:9652

Submitted by Aleksandar Trkulja - 9 years ago