I am trying to use regex to see if the given string is an IPv4 address. I want to return a boolean value True/False
depending on the string. This is my code:
import re
def isIPv4Address(inputString):
pattern = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s')
return pattern.match(inputString)
The value is null. At this point, I can tell that the function does not return a boolean value. However, all questions I see about regex and IP addresses is about writing the pattern instead of a full implementation. I know that the actual implementation shouldn't be any longer than this because it just takes the input and compares it against the regex.