Skip to content

Instantly share code, notes, and snippets.

View ZLightning's full-sized avatar
😸
Cat's rule, dogs drool!

Zigmund ZLightning

😸
Cat's rule, dogs drool!
View GitHub Profile
@ZLightning
ZLightning / ipv6.js
Last active November 2, 2017 01:02
IPv6 Regex
'use strict';
//JavaScript RegExp is compatible with Java as a string literal
//strict means :: compression will not be allowed for a single 16 bit 0 segment
var strictNonPaddedIPv6 = /^(?:(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){7}(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3})|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){1,6}:|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){1,5}:(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3})|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){1,4}:(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:)(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3})|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){1,3}:(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){2}(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3})|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){1,2}:(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){3}(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3})|(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:):(?:0(?![0-9a-fA-F])|[1-9a-fA-F][0-9a-fA-F]{0,3}:){4}(?:0(?