Question

In: Computer Science

For example My IP address 128. 0. 0. 1 My IP address 53. 20. 62. 201...

For example

My IP address 128. 0. 0. 1

My IP address 53. 20. 62. 201

My IP address 77. 122. 180. 76

My IP address 54. 33. 11. 11

My IP address 33. 33. 2. 11

My IP address 202. 29. 205. 69

My IP address 215. 18. 15. 185

My IP address 56. 66. 33. 30

How do you write a regular expression that covers all IP addresses and display all list using a loop in Python

Solutions

Expert Solution

Snipptes of source code:

source code:

# A Regular Expression is a special text string for describing a search pattern.

import re  # import regular expression module

# storing all ip_adresses in list variable "Ip_addresses"

Ip_addresses = ["128.0.0.1",

               "53.20.62.201",

               "77.122.180.76",

               "54.33.11.11",

               "33.33.2.11",

               "202.29.205.69",

               "215.18.15.185",

               "56.66.33.30"]

reg_exp_for_ip = "^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$" # regular expression to find Ip_addresses

#go through the Python official documentation for deeply understanig to these regular notation

for ip in Ip_addresses:

    print(re.findall(r"[0-9]+(?:\.[0-9]+){3}", ip))

Output:

NOTE: If you satisfied with solution then like and review in comment section


Related Solutions

1. Given the following set of exam scores: 58, 53, 56, 68, 60, 62, 65, 62,...
1. Given the following set of exam scores: 58, 53, 56, 68, 60, 62, 65, 62, 75, 75, 78, 70, 70, 75, 72, 79, 80, 85, 88, 83, 85, 87, 95, 97, 90 (I recommend Excel for all of this) a. Determine the five ranges and the frequency in each range b. Plot, in Excel, a bar graph of frequency vs range. Include a title and axis labels c. Using the same ranges determine the cumulative frequency d. Plot, in...
The requirements for your assignment are: Decode the IP address 172.16.31.255 /20 Determine the following: Subnet...
The requirements for your assignment are: Decode the IP address 172.16.31.255 /20 Determine the following: Subnet mask Multiplier Network number Subnetwork addresses Broadcast addresses This is what I came up with. Let me know if it's right or what I did wrong. Please explain. IP Address 172.16.31.255 10101100.00010000.00011111.11111111 Subnet mask 11111111.11111111.11110000.00000000 255.255.240.0 Multiplier 16 Network Number 172.16.31.0 Subnetwork Addresses    Subnetwork Addresses Broadcast Addresses 172.16.31.0 172.16.31.15 172.16.31.16 172.16.31.31 172.16.31.32 172.16.31.47 172.16.31.48 172.16.31.63 172.16.31.64 172.16.31.79 172.16.31.80 172.16.31.95 172.16.31.96 172.16.31.111 172.16.31.112 172.16.31.127 172.16.31.128...
Plase, write program in c++. IP address consists of four integers of range [0, 255] separated...
Plase, write program in c++. IP address consists of four integers of range [0, 255] separated by dots. The next three rows show three correct IP-address: 130.0.0.0 193.197.0.01 255.00.255.255 Write a program that determines whether a given string is a valid IP-address. outpot should be 1 if given IP address is valid, or 0 otherwise.
Problem 1. Network Address Suppose an ISP has the following IP address block: 130.12.128.0/23 a. Assume...
Problem 1. Network Address Suppose an ISP has the following IP address block: 130.12.128.0/23 a. Assume that the ISP wants to divide its address block (130.12.128.0/23) into two equal-sized contiguous address blocks, and give one of these address blocks to its customers (C1 and C2). Provide network addresses (of the form a.b.c.d/x) for C1 and C2. b. Now let’s assume that the ISP wants to divide its address block (130.12.128.0/23) into four equal-sized contiguous address blocks, and give one of...
Delay Industry Quality Finished Public 62 0 3 1 0 45 0 3 3 1 54...
Delay Industry Quality Finished Public 62 0 3 1 0 45 0 3 3 1 54 0 2 2 0 71 0 1 2 1 91 0 1 1 0 62 0 4 4 0 61 0 3 2 0 69 0 5 2 1 80 0 1 1 0 52 0 5 3 0 47 0 3 2 0 65 0 2 3 1 60 0 1 3 0 81 1 1 2 0 73 1 2 2 0...
1. Make a box-plot for the following data: 34 36 39 43 51 53 62 63...
1. Make a box-plot for the following data: 34 36 39 43 51 53 62 63 73 79 2. The blood pressure of 40 women have a mean of 110.8 mm hg and a standard deviation of 17.1 mm hg. Is a measurement of 181 mm hg unusual?
“My husband is 53, and I am 13 years younger. During our 20-year marriage, I have...
“My husband is 53, and I am 13 years younger. During our 20-year marriage, I have been in and out of the workforce, raising children, and getting my education. Now, I plan to return to full-time employment. I am essentially just getting my career under way as my husband approaches the completion of his. None of the retirement seminars address the issue that not all husbands and wives are the same age, nor do they retire at the same time.”...
Variable Length Subnet Mask (VLSM) and basic IP Address Design Question 1:                                &nbs
Variable Length Subnet Mask (VLSM) and basic IP Address Design Question 1:                                                                                                                                   [40 Marks] With an IP address 172.16.1.0/24, provide for a networking scheme that has 6 point-to-point routing connections, and 7 LANs. LANs are distributed in a minimum of 1 LAN per router. Three LANs have a maximum of 6 hosts each. The rest have LANs each with a maximum of 30 hosts.                                                                                        ...
Consider the following IPv4 forwarding table, using CIDR. As in exercise 1, IP address bytes are...
Consider the following IPv4 forwarding table, using CIDR. As in exercise 1, IP address bytes are in hexadecimal, and “:” is used as the separator as a reminder. destination next_hop 00:0:0:0/2 A 40:0:0:0/2 B 80:0:0:0/2 C c0:0:0:0/2 D (a). To what next_hop would each of the following be routed? 63:b1:82:15, 9e:00:15:01, de:ad:be:ef (b). Explain why every IP address is routed somewhere, even though there is no default entry. Hint: convert the first bytes to binary
[Only answer part 2] part 1: What is the public IP address of your machine? How...
[Only answer part 2] part 1: What is the public IP address of your machine? How can you know your public IP address of the machine? (Hint: ask Google.) How does a website know your public IP address? Is it different from the IP address shown on the network interface obtained by ifconfig? part2: Why are they different? (Hint: NAT.) What does this NAT thing do (briefly explain it in one sentence)? Who did it? (Hint: the VirtualBox software may...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT