python - Using RegEx to match patterns in parameters -
I want to give an IP address as a python script as a parameter and to view the IP address format I would like to use regex for supply, but I'm getting an error while trying to run the script.
The script looks like this: every time I try to run the script, I get: What's going on? Do I need to convert Try it out. Use the
If ip_check.match (ip_address) ^ syntax error: invalid syntax
ip_address to raw data before being analyzed using RegEx? Import import rg script, ip_address, client_name, printer_model, hostname, mac_ address = argv import import from
import Ip_check = re.compile (r "^ (10) \. (0) \. [0-9]? [0-9] [0-9] \. [0- 9]? [0- 9]? [ 0-9] $ ") if ip_check.match (ip_address): continue: return" invalid IP address "
r mode to create a pattern and use
: to
if and
and .
Comments
Post a Comment