RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IPv6 addresses (RFC 4291)
Expression
/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/i
Description
This regex matches all (14.095.120.151.883.281.746.489.830.170.974.347.714.655.937) valid IPv6 address _representations_ as described by RFC 4291. Current regex is valid for PCRE only, for Perl/Java/Ruby/Phython/.NET/ECMA(JavaScript)/XML specific regex visit http://home.deds.nl/~aeron/regex/
Matches
1:2:3:4:5:6:7:8 | 1:2:3:4:5:6:1.2.3.4 | 1::8 | 1::1.2.3.4 | :: | ::1.2.3.4 | 0000:000:00:0::0.0.0.0
Non-Matches
::01.02.03.04 | ::001.002.003.004 | ::011.022.033.044
Author Rating: The rating for this expression. Aeron
Source http://home.deds.nl/~aeron/regex/
Your Rating
Bad Good

Enter New Comment

Title

Name

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

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials