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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find IPv6 Address
Expression
(^\d{20}$)|(^((:[a-fA-F0-9]{1,4}){6}|::)ffff:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})){3}$)|(^((:[a-fA-F0-9]{1,4}){6}|::)ffff(:[a-fA-F0-9]{1,4}){2}$)|(^([a-fA-F0-9]{1,4}) (:[a-fA-F0-9]{1,4}){7}$)|(^:(:[a-fA-F0-9]{1,4}(::)?){1,6}$)|(^((::)?[a-fA-F0-9]{1,4}:){1,6}:$)|(^::$)
Description
This matches all valid forms of an IPv6 address. Including the compatibility form used to map IPv4 addresses. As well as the base-85 encoded integer form. It takes care of value range checking on the ipv4 part (components cannot exceed 0-255). This has been tested quite thoroughly, but considering the complexity and possibilities in the formation of an IPv6 address, matching errors are not guaranteed to be absent.
Matches
::5:aef1:ffff | ::ffff:240.65.238.22 | 0:0:0:0:0:0:0:1
Non-Matches
79250:9a0: | 8 | 91cf91d3da9
Author Rating: Not yet rated. jteeuwen
Source
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

Title: Found Issue on Wikipedia
Name: DF
Date: 2/6/2014 6:23:55 AM
Comment:
I found this valid IPv6 address on wikipedia: 2001:0db8:0000:08d3:0000:8a2e:0070:7344 However your regex states it as not valid. :(


Title: Flawed
Name: Aeron
Date: 6/17/2010 8:33:29 AM
Comment:
::1111:: is accepted


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