Skip to main content

A Python utility to validate or extract IPv4 address 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.0.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.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyipextract-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 4449e66e6540810b4087e532cd9000408696de636b73277ccc01b90445ef3d3e
MD5 ab1eb8416154438121eca27e5a2087d3
BLAKE2b-256 4c235c45f92b9160480db2201612339b222ae0b9298ebc79dcd8598d7a05010b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyipextract-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d0f5f3902eb2c5a495eb7eb9d2f79efe29b3b08f9fcc1e2704e2560ec80897
MD5 fc685cfbfa0e75f7c0d307eef83d38cc
BLAKE2b-256 259d020ebdd2c5075bf59c846466b8c0b24c9df297ad86312df66e88994a56c3

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