“Python Regex, um die IP -Adresse anzupassen” Code-Antworten

Regex, um die IP -Adresse Python zu finden

r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
Sriram MK

IP Regex Python

# Note that '^' at the beginning is optional
r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})'
Jakin687

Python Regex, um die IP -Adresse anzupassen

# Python program to validate an Ip address
 
# re module provides support
# for regular expressions
import re
 
# Make a regular expression
# for validating an Ip-address
regex = "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"
 
 
     
# Define a function for
# validate an Ip address
def check(Ip):
 
    # pass the regular expression
    # and the string in search() method
    if(re.search(regex, Ip)):
        print("Valid Ip address")
         
    else:
        print("Invalid Ip address")
     
 
# Driver Code
if __name__ == '__main__' :
     
    # Enter the Ip address
    Ip = "192.168.0.1"
     
    # calling run function
    check(Ip)
 
    Ip = "110.234.52.124"
    check(Ip)
 
    Ip = "366.1.2.2"
    check(Ip)
Helpful Hamster

Ähnliche Antworten wie “Python Regex, um die IP -Adresse anzupassen”

Fragen ähnlich wie “Python Regex, um die IP -Adresse anzupassen”

Weitere verwandte Antworten zu “Python Regex, um die IP -Adresse anzupassen” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen