Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
Python

r"
\[(?:[a-zA-Z0-9]{0,4}:?){1,8}\]|\[(?:[a-zA-Z0-9]{0,4}:?){1,4}(?:[0-9]{1,3}\.){3}[0-9]{1,3}\]
"
g

Description

It's too large to match with all which seems like an IPv6. It's not perfect, but it's detects more valid IPv6 than some others regex.

Submitted by Ajabep - 8 years ago