Erinevus lehekülje "Itx8071-task1" redaktsioonide vahel

Allikas: Kursused
Mine navigeerimisribale Mine otsikasti
8. rida: 8. rida:
  
 
2) Each part of the sequence is a hexadecimal number which must contain the
 
2) Each part of the sequence is a hexadecimal number which must contain the
following characters only: 0,1,2,3,4,5,6,7,8,9,0,A,B,C,D,E,F.  
+
following characters only: 0 1 2,3,4,5,6,7,8,9,0,A,B,C,D,E,F.  
 
Each hexadecimal number must consist of even number of digits (for example,  
 
Each hexadecimal number must consist of even number of digits (for example,  
 
2A, 1276, 1EA17C, 00A48390, etc.).  
 
2A, 1276, 1EA17C, 00A48390, etc.).  
29. rida: 29. rida:
 
B1250022,-1754FF    (the sequence has two valid parts, with the second hexadecimal having a minus sign)
 
B1250022,-1754FF    (the sequence has two valid parts, with the second hexadecimal having a minus sign)
  
+81,-A20E17,0201    (the sequence has three valid parts, with the first hexadecimal having a plus sign and the second a minus sign)
+
+81,-A20E17,0201    (the sequence has three valid parts, with the first hexadecimal having a plus sign and the second hexadecimal a minus sign)
  
 
C1,10,33,+411D8C,00,A0,-71,-80      (the sequence has eight valid parts)
 
C1,10,33,+411D8C,00,A0,-71,-80      (the sequence has eight valid parts)

Redaktsioon: 24. september 2014, kell 23:28

This homework assignment requires the knowledge from Module 3.

Please write a regular expression for matching the sequence of numbers which follows these rules:

1) The sequence consists of one or more parts. If there are two or more parts, they are separated with a comma (",") character.

2) Each part of the sequence is a hexadecimal number which must contain the following characters only: 0 1 2,3,4,5,6,7,8,9,0,A,B,C,D,E,F. Each hexadecimal number must consist of even number of digits (for example, 2A, 1276, 1EA17C, 00A48390, etc.). Also, each hexadecimal number may be prefixed by an optional minus ("-") or plus ("+") sign.

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 Java-based, Python-based, Perl-based, or any other programs for the solution.

Examples of sequences the regular expression must match:

123456 (the sequence has one valid hexadecimal number)

9A15,F3D50C (the sequence has two valid parts)

B1250022,-1754FF (the sequence has two valid parts, with the second hexadecimal having a minus sign)

+81,-A20E17,0201 (the sequence has three valid parts, with the first hexadecimal having a plus sign and the second hexadecimal a minus sign)

C1,10,33,+411D8C,00,A0,-71,-80 (the sequence has eight valid parts)