Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4})$
/
gm

Description

This performs a non-rigorous validation of IPv6 addresses. Should be used before handing off the value to a better parser/validator.

Submitted by anonymous - 9 years ago