Erinevus lehekülje "Itx8071-task1" redaktsioonide vahel
22. rida: | 22. rida: | ||
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. | ||
+ | |||
+ | Examples of sequences the regular expression must match: | ||
+ | |||
+ | speed="60kmph" (the sequence has one valid element) | ||
+ | |||
+ | visitors=57,temp="36.4F",prefix="+372" (the sequence has three valid elements) | ||
+ | |||
+ | altitude="5000m",origin="",type="balloon",gas="oxygen",flammable="no",engines=0,heaters=1,crew=2 (the sequence has eight valid elements) | ||
+ | |||
+ | Examples of sequences the regular expression must NOT match: | ||
+ | |||
+ | speed="60kmph", (there is a comma after the first sequence element, but the second element is missing) | ||
+ | |||
+ | date=,visitors=1011 (the first sequence element has a keyword but no value) | ||
+ | |||
+ | date="Sep 10 2015",city=tallinn,visitors=1011 (the second sequence element has a non-numerical value, but it is not enclosed in double quotes) | ||
+ | |||
+ | speed="60kmph",,type="car" (the second sequence element is missing) | ||
+ | |||
+ | speed="60kmph",type="car",manufacturer=honda" (the third sequence element has a non-numerical value, but one of the enclosing double quotes is missing) | ||
+ | |||
+ | speed2="60kmph",type="car",manufacturer="honda" (the first sequence element has a keyword which contains illegal character 2) | ||
+ | |||
+ | date="Sep 10 2015",=tallinn,visitors=1011 (the second sequence element does not have a keyword) | ||
+ | |||
+ | visitors=57,temp="36.4F", prefix="+372" (there is an illegal space character after the second separating comma) | ||
+ | |||
+ | speed=60 ,gear=4 (there is an illegal space character before the first separating comma) |
Redaktsioon: 27. september 2015, kell 20:50
This homework assignment requires the knowledge from Module 3.
Please write a regular expression for matching the sequence of keyword-value pairs which follows these rules:
1) The sequence consists of one or more elements. If there are two or more elements, they are separated with a comma (,) character.
2) Each element of the sequence is a keyword-value pair, where keyword and value are separated with an equal sign (=) character. Each keyword must be a sequence of one or more letters, while each value is a sequence of zero or more characters which are not double quotes ("). If the value is either empty or contains one or more non-digits, the value must be enclosed in double quotes ("). For non-empty values that consist of digits only, the surrounding double quotes may be omitted. Here are examples of valid keyword-value pairs:
visitors=112
temperature="12.3C"
language="english"
countries="US,UK,Germany,France"
age=26
origin=""
score="67.8"
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:
speed="60kmph" (the sequence has one valid element)
visitors=57,temp="36.4F",prefix="+372" (the sequence has three valid elements)
altitude="5000m",origin="",type="balloon",gas="oxygen",flammable="no",engines=0,heaters=1,crew=2 (the sequence has eight valid elements)
Examples of sequences the regular expression must NOT match:
speed="60kmph", (there is a comma after the first sequence element, but the second element is missing)
date=,visitors=1011 (the first sequence element has a keyword but no value)
date="Sep 10 2015",city=tallinn,visitors=1011 (the second sequence element has a non-numerical value, but it is not enclosed in double quotes)
speed="60kmph",,type="car" (the second sequence element is missing)
speed="60kmph",type="car",manufacturer=honda" (the third sequence element has a non-numerical value, but one of the enclosing double quotes is missing)
speed2="60kmph",type="car",manufacturer="honda" (the first sequence element has a keyword which contains illegal character 2)
date="Sep 10 2015",=tallinn,visitors=1011 (the second sequence element does not have a keyword)
visitors=57,temp="36.4F", prefix="+372" (there is an illegal space character after the second separating comma)
speed=60 ,gear=4 (there is an illegal space character before the first separating comma)