Giter VIP home page Giter VIP logo

ipv4-ipv6-regex's Introduction

IPv4-IPv6-Regex

This regex matches IPv4 and IPv6 format (compatible with IPv6 short format like fe80::1)

DISCLAIMER: USE AT YOUR OWN RISK. DO NOT USE THIS REGEX FOR SECURITY APPLICATIONS UNTIL YOU HAVE TESTED IT MULTIPLE TIMES. ERRORS CAN OCCUR.

demo3

How to use ?

  1. Copy and paste the content in the regex.txt file.
  2. If you want to check an input, just use it like this (don't forget to sanitize and trim the text input before).
  3. To search multiple IPs in a text file, remove the "^" at the beginning and the "$" at the end.

Features:

  • Supports general IPv4 formats shortened shapes.
  • Supports general IPv6 formats shortened shapes.

Testing:

  1. Go to https://regex101.com/
  2. Paste the regex.txt content in the regular expression field.
  3. Paste the ip-samples.txt content in the text string.
  4. Try with your own IPs.

Notes and improvements:

This regex was tested with more than 1,000 IPs with Python and was working. However, there are also thousands of IP formats.
This is why many of the IP regex patterns found online are BAD and easily breakable !
This one does not except the rule. So if an IP doesn’t match this regex, or a field that appears valid even though it’s not a valid IP, please correct the regex and share it!

ipv4-ipv6-regex's People

Contributors

numnumv avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.