Regular Expressions 101

Community Patterns

1...34567...900

Community Library Entry

5

Regular Expression
PCRE (PHP <7.3)

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

Description

Handle all condition for ipv6 example:

  1. FE80::8329
  2. FE80::FFFF:8329
  3. FE80::B3FF:FFFF:8329
  4. FE80::0202:B3FF:FFFF:8329
  5. FE80::0000:0202:B3FF:FFFF:8329
  6. FE80::0000:0000:0202:B3FF:FFFF:8329
  7. FE80:0000:0000:0000:0202:B3FF:FFFF:8329
Submitted by Lim Yew Teck, Nicholas - 9 years ago