“IP Regex Python” Kode Jawaban

regex untuk menemukan alamat ip python

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 untuk mencocokkan alamat IP

# 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

Jawaban yang mirip dengan “IP Regex Python”

Pertanyaan yang mirip dengan “IP Regex Python”

Lebih banyak jawaban terkait untuk “IP Regex Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya