Erinevus lehekülje "Itx8071-task1" redaktsioonide vahel
15. rida: | 15. rida: | ||
Please note that for accomplishing the task, one regular expression has | 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. | + | 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., | It is not acceptable to submit the solution in a fragmented way (e.g., | ||
several isolated expressions for addressing different parts of the task). | several isolated expressions for addressing different parts of the task). | ||
− | Also, it is not allowed to submit Java | + | Also, it is not allowed to submit programs in Java, Python, Perl, |
− | or any other | + | (or any other language) for the solution. |
'''Examples of sequences the regular expression must match''': | '''Examples of sequences the regular expression must match''': |
Redaktsioon: 24. september 2014, kell 23:45
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 a b c d e f. Each hexadecimal number must consist of even number of hexadecimal 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 programs in Java, Python, Perl, (or any other language) 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)
Examples of sequences the regular expression must NOT match:
- 11, 22 (the second part begins with a space character which is illegal)
- A 2,33 (the first part contains a space character which is illegal)
- 9A, (the first part ends with comma, but there is no following second part)
- 1G9A (the number contains an illegal character G)
- -+F2 (the number begins with two signs, but only one sign is allowed)
- 2-1 (the minus sign illegally appears in the middle of a number)
- 72,,89 (the second part of the sequence is empty)
- 12,-ABC,+84 (the second part does not consist of even number of hexadecimal digits)
- P$12,43,22 (the sequence begins with illegal characters)
- B2C3,12+T (the sequence ends with illegal characters)