Erinevus lehekülje "Itx8071-task1" redaktsioonide vahel

Allikas: Kursused
Mine navigeerimisribale Mine otsikasti
 
(ei näidata sama kasutaja 58 vahepealset redaktsiooni)
1. rida: 1. rida:
 
This homework assignment requires the knowledge from Module 3.
 
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: ===
+
=== Please write a regular expression for matching the sequence of software module names and optional version numbers, so that the sequence will follow these rules: ===
  
# 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).
 
# 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.  
+
* Each part of the sequence is a software module name which is optionally followed by a version number. If the version number is present, there must be a dash ("-") character between the software module name and the version number. If there is no version number, the use of dash character after the software module name is not permitted.
'''Finally, if the solution only works with the examples provided below but does NOT meet the task specification, it will be treated as incorrect.'''
+
 
 +
* Software module name must contain at least one character and must begin with a letter, and may contain letters and digits only.
 +
 
 +
* The version number consists of one or more elements. If there are two or more version number elements, these elements must be separated with a dot (".") character. Note that the dot character may not appear before the first or after the last element. Each version number element must be a sequence of one or more digits which may be optionally followed by one letter.
 +
 
 +
Please note that for accomplishing the task, '''one regular expression has to be submitted which is suitable for use with the egrep or pcre2grep 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: ===
 
=== Examples of sequences the regular expression must match: ===
  
  myhost:123:22/tcp
+
  m4-1.4.16
(the sequence has one valid part -- a hostname with two port specifications)  
+
(the sequence has one valid part -- a software module name with a version number of 3 elements)  
+
 
  dbserver:161/udp:80,mailserver:25/tcp
+
  coreutils,pcre-8.32
(the sequence has two valid parts)  
+
(the sequence has two valid parts -- note that the first part does not have a version number)  
+
 
  fileserver:2049:22/tcp:8080,mailserver:443/tcp:22/tcp:123/udp,myhost
+
  libtasn1-4.09a,GeoIP-1.5.0,iwl6000g2a
(the sequence has three valid parts, with the first and second parts having port specifications)  
+
(the sequence has three valid parts, with the first and second parts having version numbers)  
+
 
  serverA,serverB,serverC:20:21:22:23:25,serverD,serverE
+
  iwl2030,a12bcd3456ef78gh,mydatabase-13i.222.5b,e2fsprogs,PyYAML
(the sequence has five valid parts, where only the third hostname has port numbers)  
+
(the sequence has five valid parts, where only the third part has a version number)
  
 
=== Examples of sequences the regular expression must NOT match: ===
 
=== Examples of sequences the regular expression must NOT match: ===
  
  serverA, serverB:80
+
  coreutils, pcre-8.32
(the second part begins with a space character which is illegal)  
+
(the second part begins with a space character which is illegal)  
+
 
  serverA 22,myhost
+
  coreutils 8.22,pcre--8.32
(the first part contains a space character which is illegal)  
+
(the first part contains a space character which is illegal; also, in the second part the software module name and version number are separated by two dash characters which is illegal)  
+
 
  myhost:80,
+
  m4-1.4.16,
(the first part ends with comma, but there is no following second part)  
+
(the first part ends with comma, but there is no following second part)  
+
 
  myhost6
+
  my_db
(the hostname contains an illegal character 6)  
+
(the software module name contains an illegal character _)  
 
+
 
  myhost:9A
+
  mydb-11A3.1
(the port number contains an illegal character A)  
+
(the first version number element contains a character A, but A is not the last character of the version number element)  
+
 
  myhost::80
+
  mydb-11..2
(two colons precede the port number)  
+
(version number contains two dots, but there is no version number element between them)  
+
 
  myhost:80/
+
  mydb-
(port number is followed by /, but there is no transport protocol string)  
+
(software module name is followed by -, but there is no version number)  
+
 
  server:80tcp
+
  mydb-12ab.1
(there is no separating / character between port number and transport protocol string)
+
(the first version number element ends with more than one letter which is illegal)
 
+
 
  serverA,,serverC
+
  mydb,,mydaemon
(the second part of the sequence is empty)  
+
(the second part of the sequence is empty)  
 
+
 
  !"serverA:121,myhost,serverB:22
+
  !"libtasn1-4.09a,GeoIP-1.5.0,iwl6000g2a
(the sequence begins with illegal characters)  
+
(the sequence begins with illegal characters)  
+
 
  serverA:80,myhost:312/tcp+T
+
  coreutils-8.22,pcre-8.32+%
(the sequence ends with illegal characters)
+
(the sequence ends with illegal characters)

Viimane redaktsioon: 22. september 2025, kell 09:18

This homework assignment requires the knowledge from Module 3.

Please write a regular expression for matching the sequence of software module names and optional version numbers, so that the sequence will follow 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 software module name which is optionally followed by a version number. If the version number is present, there must be a dash ("-") character between the software module name and the version number. If there is no version number, the use of dash character after the software module name is not permitted.
  • Software module name must contain at least one character and must begin with a letter, and may contain letters and digits only.
  • The version number consists of one or more elements. If there are two or more version number elements, these elements must be separated with a dot (".") character. Note that the dot character may not appear before the first or after the last element. Each version number element must be a sequence of one or more digits which may be optionally followed by one letter.

Please note that for accomplishing the task, one regular expression has to be submitted which is suitable for use with the egrep or pcre2grep 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:

m4-1.4.16

(the sequence has one valid part -- a software module name with a version number of 3 elements)

coreutils,pcre-8.32

(the sequence has two valid parts -- note that the first part does not have a version number)

libtasn1-4.09a,GeoIP-1.5.0,iwl6000g2a

(the sequence has three valid parts, with the first and second parts having version numbers)

iwl2030,a12bcd3456ef78gh,mydatabase-13i.222.5b,e2fsprogs,PyYAML

(the sequence has five valid parts, where only the third part has a version number)

Examples of sequences the regular expression must NOT match:

coreutils, pcre-8.32

(the second part begins with a space character which is illegal)

coreutils 8.22,pcre--8.32

(the first part contains a space character which is illegal; also, in the second part the software module name and version number are separated by two dash characters which is illegal)

m4-1.4.16,

(the first part ends with comma, but there is no following second part)

my_db

(the software module name contains an illegal character _)

mydb-11A3.1

(the first version number element contains a character A, but A is not the last character of the version number element)

mydb-11..2

(version number contains two dots, but there is no version number element between them)

mydb-

(software module name is followed by -, but there is no version number)

mydb-12ab.1

(the first version number element ends with more than one letter which is illegal)

mydb,,mydaemon

(the second part of the sequence is empty)

!"libtasn1-4.09a,GeoIP-1.5.0,iwl6000g2a

(the sequence begins with illegal characters)

coreutils-8.22,pcre-8.32+%

(the sequence ends with illegal characters)