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.2.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.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyipextract-1.0.2.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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.5

File hashes

Hashes for pyipextract-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6d974c791a22bbba45e4459543b0c89fae2278b0316b1e190cae34c4b7ed2573
MD5 741f9ad1e22eef05ca5df221eb35b30d
BLAKE2b-256 054e7a1a915dc0fb4441758691ad7c0f5c696232c85bf300cfca86ada23d34d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyipextract-1.0.2-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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.5

File hashes

Hashes for pyipextract-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5872c347e768a75adcaeede636d8c7aea974302ebe2a0e87837788a7e3a5d82a
MD5 914d29756c2f43e725c04a967bbccd22
BLAKE2b-256 5f2a9b981735663152510ff858632bea9bb434b0a77d93e1a7ded6bb4cb3e2ff

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