Skip to main content

A Python utility to validate or extract IPv4 addresses from strings

Project description

pyipextract

Python utility to extract or validate IPv4 addresses

IPv4 Extraction

  • It can extract valid IPv4 addresses from a given string
  • Returns a list of all valid IPv4 addresses extracted from a given string

IPv4 Validation

  • Can also be used just to validate an IPv4address

Installation

pip install pyipextract

How to use

Here's an example of calling IPExtractor constructor and using the extraction or just validation mechanisms

Extraction

from pyipextract import IPExtractor

input_str = "This is a string which contains valid IPs 192.168.1.1, 1.1.1.1 and an invalid IP 256.444.22.22"
ip_extractor = IPExtractor()
extracted_ips = ip_extractor.extract(input_str)
print(extracted_ips) 

Output:

['192.168.1.1', '1.1.1.1']

Validation

from pyipextract import IPExtractor

ips = ["192.168.1.1", "256.444.22.22", "1.1.1.1111"]
ip_extractor = IPExtractor()
for value in ips:
    if ip_extractor.validate(value):
        print("Valid IP: {}".format(value))
    else:
        print("Invalid IP: {}".format(value))

Output

Valid IP: 192.168.1.1
Invalid IP: 256.444.22.22
Invalid IP: 1.1.1.1111

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyipextract-1.0.1.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyipextract-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pyipextract-1.0.1.tar.gz.

File metadata

  • Download URL: pyipextract-1.0.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for pyipextract-1.0.1.tar.gz
Algorithm Hash digest
SHA256 257bb2fbb862026ba84eecf6b78014f3f1550ea6982c9056a555a1482a4b16a8
MD5 286ee4d6f57b7475f63ccdeec6928b45
BLAKE2b-256 1117d468bf5bbaa0fb153918240704b2bd3efc66864de70ef2285fe9ebc92841

See more details on using hashes here.

File details

Details for the file pyipextract-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyipextract-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for pyipextract-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bf317ca3a7d21b032e5d9f442ce55aab05824d74470727ca5a96fb3c9813d3b3
MD5 525b223ff5013c3f61ec691d3c7e6572
BLAKE2b-256 048d49c384de5139824f8777926ef2f3d88a0453362dac75f37120c394881033

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page