Erinevus lehekülje "Itx8071-task1" redaktsioonide vahel
Mine navigeerimisribale
Mine otsikasti
5. rida: | 5. rida: | ||
# The sequence consists of one or more parts. If there are two or more parts, they are separated with a comma (",") character. | # The sequence consists of one or more parts. If there are two or more parts, they are separated with a comma (",") character. | ||
# Each part of the sequence is a hostname which must consist of letters only, with optional port specifications following the hostname. If port specifications are present, each specification is preceded by a single colon (":") character. A valid specification consists of decimal digits that define the port number, and port number may be followed by either "/tcp" or "/udp" suffix (other suffixes are not allowed). | # Each part of the sequence is a hostname which must consist of letters only, with optional port specifications following the hostname. If port specifications are present, each specification is preceded by a single colon (":") character. A valid specification consists of decimal digits that define the port number, and port number may be followed by either "/tcp" or "/udp" suffix (other suffixes are not allowed). | ||
− | + | # It is not mandatory to verify that port number falls into range 1..65535, and it is sufficient to check that port number consists of digits only. | |
− | |||
Please note that for accomplishing the task, one regular expression has to be submitted which is '''suitable for use with the ''egrep'' or ''pcregrep'' tool'''. It is not acceptable to submit the solution in a fragmented way (e.g., several isolated expressions for addressing different parts of the task). Also, it is not allowed to submit programs in Java, Python, Perl (or any other language) for the solution. | Please note that for accomplishing the task, one regular expression has to be submitted which is '''suitable for use with the ''egrep'' or ''pcregrep'' tool'''. It is not acceptable to submit the solution in a fragmented way (e.g., several isolated expressions for addressing different parts of the task). Also, it is not allowed to submit programs in Java, Python, Perl (or any other language) for the solution. |
Redaktsioon: 13. oktoober 2019, kell 18:40
This homework assignment requires the knowledge from Module 3.
Please write a regular expression for matching the sequence of hostnames and optional port specifications which follows these rules:
- The sequence consists of one or more parts. If there are two or more parts, they are separated with a comma (",") character.
- Each part of the sequence is a hostname which must consist of letters only, with optional port specifications following the hostname. If port specifications are present, each specification is preceded by a single colon (":") character. A valid specification consists of decimal digits that define the port number, and port number may be followed by either "/tcp" or "/udp" suffix (other suffixes are not allowed).
- It is not mandatory to verify that port number falls into range 1..65535, and it is sufficient to check that port number consists of digits only.
Please note that for accomplishing the task, one regular expression has to be submitted which is suitable for use with the egrep or pcregrep tool. It is not acceptable to submit the solution in a fragmented way (e.g., several isolated expressions for addressing different parts of the task). Also, it is not allowed to submit programs in Java, Python, Perl (or any other language) for the solution. Finally, if the solution only works with the examples provided below but does NOT meet the task specification, it will be treated as incorrect.
Examples of sequences the regular expression must match:
myhost:123:22/tcp (the sequence has one valid part -- a hostname with two port specifications) dbserver:161/udp:80,mailserver:25/tcp (the sequence has two valid parts) fileserver:2049:22/tcp:8080,mailserver:443/tcp:22/tcp:123/udp,myhost (the sequence has three valid parts, with the first and second parts having port specifications) serverA,serverB,serverC:20:21:22:23:25,serverD,serverE (the sequence has five valid parts, where only the third hostname has port numbers)
Examples of sequences the regular expression must NOT match:
serverA, serverB:80 (the second part begins with a space character which is illegal) serverA 22,myhost (the first part contains a space character which is illegal) myhost:80, (the first part ends with comma, but there is no following second part) myhost6 (the hostname contains an illegal character 6) myhost:9A (the port number contains an illegal character A) myhost::80 (two colons precede the port number) myhost:80/ (port number is followed by /, but there is no transport protocol string) server:80tcp (there is no separating / character between port number and transport protocol string) serverA,,serverC (the second part of the sequence is empty) !"serverA:121,myhost,serverB:22 (the sequence begins with illegal characters) serverA:80,myhost:312/tcp+T (the sequence ends with illegal characters)