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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(^(([0-9A-F]{1,4}(((:[0-9A-F]{1,4}){5}::[0-9A-F]{1,4})|((:[0-9A-F]{1,4}){4}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,1})|((:[0-9A-F]{1,4}){3}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,2})|((:[0-9A-F]{1,4}){2}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,3})|(:[0-9A-F]{1,4}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,4})|(::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,5})|(:[0-9A-F]{1,4}){7}))$|^(::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,6})$)|^::$)|^((([0-9A-F]{1,4}(((:[0-9A-F]{1,4}){3}::([0-9A-F]{1,4}){1})|((:[0-9A-F]{1,4}){2}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,1})|((:[0-9A-F]{1,4}){1}::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,2})|(::[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,3})|((:[0-9A-F]{1,4}){0,5})))|([:]{2}[0-9A-F]{1,4}(:[0-9A-F]{1,4}){0,4})):|::)((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})$$
Description
Matches all IPv6 text representations as defined within RFC 2373. Fairly verbose
Matches
::0:0:0:FFFF:129.144.52.38 | FEDC:BA98::3210:FEDC:BA98:7654:3210 | ::13.1.68.3
Non-Matches
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210:1234 | 3210:FEDC:BA98:7654:3210:1234 | :FEDC:BA98:7654:3210:
Author Rating: Not yet rated. Glynn Beeken
Source IPv6 Complete
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: Trailing :: not supported
Name: Marcus
Date: 11/20/2009 11:25:26 AM
Comment:
All variants of trailing zeroes are not supported. e.g. 1::, 1:1:: etc, pp.


Title: Trailing :: not supported
Name: Marcus
Date: 11/20/2009 11:25:03 AM
Comment:
All variants of trailing zeroes are not supported. e.g. 1::, 1:1:: etc, pp.


Title: Incompleet
Name: Aeron
Date: 10/15/2009 4:21:56 AM
Comment:
Doesn't work for : 1111:: 1111:2222:: etc. or AAAA::1.2.3.4 AAAA:BBBB::1.2.3.4 etc.


Title: This is awesome!
Name: Ray Case - Java Developer
Date: 2/12/2008 1:19:52 PM
Comment:
This works strictly for IPv6 addresses. I added a direct test for ipv4 preceding this. To get this to work with Java, you need to escape the backslash '\' as '\\' So in the regex: {0,2})\.){3} becomes: {0,2})\\.){3} Also, I added: 0-9A-Fa-f to the [0-9A-F] ranges so I didn't have to convert to uppercase first.


Title: This is awesome!
Name: Ray Case - Java Developer
Date: 2/12/2008 1:19:32 PM
Comment:
This works strictly for IPv6 addresses. I added a direct test for ipv4 preceding this. To get this to work with Java, you need to escape the backslash '\' as '\\' So in the regex: {0,2})\.){3} becomes: {0,2})\\.){3} Also, I added: 0-9A-Fa-f to the [0-9A-F] ranges so I didn't have to convert to uppercase first.


Title: Not working with Java's Pattern class
Name: Jeybas
Date: 11/14/2007 12:02:55 PM
Comment:
Do any of these work with the Pattern class in Java which deals with regualr expressions. I can't seem to get any working.


Title: Not working with Java's Pattern class
Name: Jeybas
Date: 11/14/2007 12:02:43 PM
Comment:
Do any of these work with the Pattern class in Java which deals with regualr expressions. I can't seem to get any working.


Title: Strange side-effect alternating two IP patterns
Name: Mark Nicholson
Date: 12/30/2005 7:13:07 AM
Comment:
Damn... ignore those. Based on the assumptions in my first comment, the following works for IPv6 addresses (excluding mixed environment): (([1-9a-fA-F][\da-fA-F]{1,3}|[\da-fA-F][1-9a-fA-F][\da-fA-F]{0,2}|[\da-fA-F]{0,2}[1-9a-fA-F][\da-fA-F]|[\da-fA-F]{0,3}[1-9a-fA-F]):(([\da-fA-F]{1,4}:){6}|([\da-fA-F]{1,4}:){4}:|(([\da-fA-F]{1,4}:){3}:([\da-fA-F]{1,4}:)?)|([\da-fA-F]{1,4}:){2}:([\da-fA-F]{1,4}:){0,2}|([\da-fA-F]{1,4}:):([\da-fA-F]{1,4}:){0,3}|:([\da-fA-F]{1,4}:){0,4})([1-9a-fA-F][\da-fA-F]{1,3}|[\da-fA-F][1-9a-fA-F][\da-fA-F]{0,2}|[\da-fA-F]{0,2}[1-9a-fA-F][\da-fA-F]|[\da-fA-F]{0,3}[1-9a-fA-F])) and the following works for mixed environment only: ((((0{1,4}:){5}(0{1,4}|[fF]{4}):)|(::([fF]{4}:)?))?((25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d?)(\.(25[0-4]|2[0-4]\d|1\d{2}|([1-9]?\d))){2}(\.(25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d?)))) But combine the in the form (<first>|<second>) and all of a sudden you can enter additional characters as well as the IPv4 address. Any ideas?


Title: Leading and trailing zeros in IPv6 or mixed environment domain-literals for email addressing
Name: Mark Nicholson
Date: 12/29/2005 1:53:04 PM
Comment:
\[(([a-fA-F1-9][a-fA-F\d]{1,3}|[a-fA-F\d][a-fA-F1-9][a-fA-F\d]{0,2}|[a-fA-F\d]{0,2}[a-fA-F1-9][a-fA-F\d]|[a-fA-F\d]{0,3}[a-fA-F1-9]):((([a-fA-F\d]{1,4}:){6})|(([a-fA-F\d]{1,4}:){4}:)|([a-fA-F\d]{1,4}:){3}:([a-fA-F\d]{1,4}:)?)|([a-fA-F\d]{1,4}:){2}:([a-fA-F\d]{1,4}:){0,2})|([a-fA-F\d]{1,4}:):([a-fA-F\d]{1,4}:){0,3})|(:([a-fA-F\d]{1,4}:){0,4}))([a-fA-F1-9][a-fA-F\d]{1,3}|[a-fA-F\d][a-fA-F1-9][a-fA-F\d]{0,2}|[a-fA-F\d]{0,2}[a-fA-F1-9][a-fA-F\d]|[a-fA-F\d]{0,3}[a-fA-F1-9]))|((((0{1,4}:){5}(0{1,4}|[fF]{4}):)|(::([fF]{4}:)?))?(25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d?(\.(25[0-4]|2[0-4]\d|1\d{2}|[1-9]?\d)){2}\.(25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d?)))\]


Title: Leading and trailing zeros in IPv6 or mixed environment domain-literals for email addressing
Name: Mark Nicholson
Date: 12/29/2005 1:51:40 PM
Comment:
I'm looking at this from the perspective of email addressing for which IPv4 effectively restricts the use of zero values to the middle two octects (at least I don't believe you can use the network address) - does the same hold true for IPv6 does anyone know? Similarly - apart from the two ranges (:: and ::FFFF:) for mixed environment representation of IPv4 addresses - are leading zeros allowed? Assuming they are not (big assumption) then I've come up with the following for the domain-literal section of the expression: \[(([a-fA-F1-9][a-fA-F\d]{1,3}|[a-fA-F\d][a-fA-F1-9][a-fA-F\d]{0,2}|[a-fA-F\d]{0,2}[a-fA-F1-9][a-fA-F\d]|[a-fA-F\d]{0,3}[a-fA-F1-9]):((([a-fA-F\d]{1,4}:){6})|(([a-fA-F\d]{1,4}:){4}:)|([a-fA-F\d]{1,4}:){3}:([a-fA-F\d]{1,4}:)?)|([a-fA-F\d]{1,4}:){2}:([a-fA-F\d]{1,4}:){0,2})|([a-fA-F\d]{1,4}:):([a-fA-F\d]{1,4}:){0,3})|(:([a-fA-F\d]{1,4}:){0,4}))([a-fA-F1-9][a-fA-F\d]{1,3}|[a-fA-F\d][a-fA-F1-9][a-fA-F\d]{0,2}|[a-fA-F\d]{0,2}[a-fA-F1-9][a-fA-F\d]|[a-fA-F\d]{0,3}[a-fA-


Title: lower case hex letters
Name: David Mueller
Date: 2/18/2005 3:42:11 PM
Comment:
Minor variation that allows lower case letters to be used as hex digits a-f as well as upper case A-F ^(^(([0-9A-Fa-f]{1,4}(((:[0-9A-Fa-f]{1,4}){5}::[0-9A-Fa-f]{1,4})|((:[0-9A-Fa-f]{1,4}){4}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})|((:[0-9A-Fa-f]{1,4}){3}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})|((:[0-9A-Fa-f]{1,4}){2}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})|(:[0-9A-Fa-f]{1,4}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})|(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})|(:[0-9A-Fa-f]{1,4}){7}))$|^(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,6})$)|^::$)|^((([0-9A-Fa-f]{1,4}(((:[0-9A-Fa-f]{1,4}){3}::([0-9A-Fa-f]{1,4}){1})|((:[0-9A-Fa-f]{1,4}){2}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,1})|((:[0-9A-Fa-f]{1,4}){1}::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,2})|(::[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,3})|((:[0-9A-Fa-f]{1,4}){0,5})))|([:]{2}[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,4})):|::)((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{0,2})$$


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