- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find IPv6 addresses including compressed and IPv4-embedded variants (RFC 2373)
This RE recognizes IPv6 addresses for all the representations described by RFC 2373: 1) extended format (with both upper and lowercase HEX) 2) compressed format (eg 2001::6:a) 3) IPv4-embedded format (eg ::ffff: limited to addresses of the traditional dual-stack configuration Resulting from observation of real-world implementations, case 2) is extended to allow "::" for one 0-group alone. Although the RFC is clear on "::" being for "multiple groups of 16-bits of zeros" only, some tools like "dig" for the mac produce those values. The RE is simple and quite elegant; it has been tested on over 300 IPv6 addresses collected by dig-ing IPv6-enabled domains; it is used in sshguard's log parser, see .
2001:470:b0b4:1:280:c6ff:fef2:9410 | 2001:868:100::3 | 2001:888:144a::a441:888:1002 | ::1 | a:b:: | ::FFFF:
1:2:3:4:5:6:7:8:9 | a::b::c | x:x:x:x:x:x:x:x
Author Rating: Not yet rated. mij
Your Rating
Bad Good

Enter New Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Not matched.. need to get clarified
Name: Amarnath
Date: 12/24/2013 1:54:21 AM
::FFFF: is not matched...

Title: Flawed
Name: Aeron
Date: 6/17/2010 8:55:05 AM
Does not accept: 1111:2222:3333:4444:5555:6666:7777:: 1111:2222:3333:4444:5555:6666::8888 ::2222:3333:4444:5555:6666:7777:8888 1111:2222:3333:4444:5555:6666: 1111:2222:3333:4444:5555:: 1111:2222:3333:4444:: 1111:2222:3333:: 1111:2222:: 1111:: 1111:2222:3333:4444::6666: 1111:2222:3333::6666: 1111:2222::6666: 1111::6666: ::6666: 1111:2222:3333::5555:6666: 1111:2222::5555:6666: 1111::5555:6666: ::5555:6666: 1111:2222::4444:5555:6666: 1111::4444:5555:6666: ::4444:5555:6666: 1111::3333:4444:5555:6666: ::2222:3333:4444:5555:6666:

Title: Sorry
Name: Aeron
Date: 6/17/2010 8:45:44 AM
Ignore previous comment, mixed up regex.

Title: Flawed
Name: Aeron
Date: 6/17/2010 8:42:30 AM
::2222:3333:4444:5555:7777:8888:: is accepted

Copyright © 2001-2018, | ASP.NET Tutorials