Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Problem with IPv6 validation #2

Open
MTRNord opened this issue Jun 21, 2016 · 0 comments
Open

Problem with IPv6 validation #2

MTRNord opened this issue Jun 21, 2016 · 0 comments

Comments

@MTRNord
Copy link

MTRNord commented Jun 21, 2016

Hi I use following code to validate IPv6. This Code says false but the same regex at the site http://www.regextester.com/25 says true

var ipv6_val = new Regex(/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/g);

if (ipv6_val.test("2a03:2267:4e6f:7264:56e6:fcff:fed5:2e6c")) {
    console.log("true")
}else{
    console.log("false")
}

Is the error caused by the module or by the regex?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant