Created
May 13, 2022 17:18
-
-
Save james-see/dedad853345e192146766e35c569b58b to your computer and use it in GitHub Desktop.
check for ip4 in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
class IsIPv4Address: | |
# noinspection PyPep8Naming | |
@classmethod | |
def is_IPv4_address(cls, input_str: str) -> bool: | |
pattern = r"\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b" | |
if re.fullmatch(pattern, input_str): | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment