Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

UESTION 12 Write a Regular Expression (just the expression) that will match agai

ID: 3842646 • Letter: U

Question

UESTION 12

Write a Regular Expression (just the expression) that will match against any valid "dotted" IP4 address. For simplicity, consider the address as valid if it is in the following form:

A.B.C.D where A, B, C, and D are any numbers between 0 and 255.

Examples of valid addresses (at least valid for our purposes):

0.0.0.0

255.255.255.255

192.168.0.1

(Note that some some of these examples are not actually valid IP addresses due to more complicated numbering rules, but we're just looking at the basic structure here!)

Examples of invalid addresses (these are all truly invalid):

300.0.0.0

27.34

1.2.3.555

Hint: you may want to consider the case of a 3 digit number differently than a 1 or two digit number.

Explanation / Answer

IP4 Address Regular Expression Pattern

Description

Whole combination means, digit from 0 to 255 and follow by a dot “.”, repeat 4 time and ending with no dot “.” Valid IP address format is “0-255.0-255.0-255.0-255”.