Why not use a library function to validate the ip address?
>>> ip="241.1.1.112343434"
>>> socket.inet_aton(ip)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.error: illegal IP address string passed to inet_aton
More Related Contents:
- Take first some character of string but if particular character will come consider that character also
- How to extract numbers from a string in Python?
- Is it worth using Python’s re.compile?
- Extract part of a regex match
- Regular expression matching a multiline block of text
- What is the difference between re.search and re.match?
- How can I do multiple substitutions using regex?
- regex error – nothing to repeat
- How to match any string from a list of strings in regular expressions in python?
- How to timeout function in python, timeout less than a second
- Split string based on regex
- Find all Chinese text in a string using Python and Regex
- How to use re to find consecutive, repeated chars
- RegEx Get string between two strings that has line breaks
- Python – re.findall returns unwanted result
- Why Does a Repeated Capture Group Return these Strings?
- Splitting out the output of ps using Python
- How to use regex to find all overlapping matches
- How can a recursive regexp be implemented in python?
- Python regular expression pattern * is not working as expected
- Split string at every position where an upper-case word starts
- FutureWarning: The default value of regex will change from True to False in a future version
- Why does this take so long to match? Is it a bug?
- Regex matching – why does this not match and return None?
- How do I verify that a string only contains letters, numbers, underscores and dashes? [duplicate]
- Python regex findall
- Python regex: matching a parenthesis within parenthesis
- Regexp finding longest common prefix of two strings
- Splitting a math expression string into tokens in Python
- Download all pdf files from a website using Python