Sonoma State University
Department of Computer Science
CS-210: Introduction to Unix
Exercise 11: Regular Expressions

Objective

Developing regular expressions (regex) for password validation and data extraction.

Regex for password validation

  1. A password is valid if it contains only uppercase letters (A-Z), lowercase letters (a-z), digits (0-9), and special symbols (":", "&", "%", "#") and is between twelve and twenty bytes (inclusive) in length. Write an egrep command using POSIX Extended Regular Expression to match this pattern. Note: Please see page 251 (Chapter 19) of our textbook for information about regular expressions including POSIX Extended Regular Expressions.

Regex for data extraction

For questions two through five, you will use a publically available dataset in CSV (comma separated values) format for electric vehicles at https://catalog.data.gov/dataset/electric-vehicle-population-data. Please download the dataset using the following command:

wget https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD -O ev.csv

Please answer the following questions using the CSV dataset above:

  1. How many Nissan electric vehicles are listed? Please paste the entire command you entered on Blue to answer this question.
  2. How many Tesla Model 3 electric vehicles are listed? Please paste the entire command you entered on Blue to answer this question.
  3. What is the greatest distance a battery electric vehicle (BEV) can travel? Please paste the entire command you entered on Blue to answer this question. Hint: I'm looking for a single number, not a list of numbers.
  4. List the distinct manufacturers (i.e. MAKE) that begin with the letter "L". Please paste the entire command you entered on Blue to answer this question.

Submission Instructions:

Please submit your answers to Canvas for the five questions above.

Exercise 11 Rubric

CRITERIA RATINGS POINTS
Question 1: Proficient
0.6 points

Student provided an egrep command using a POSIX Extended Regular Expression which will properly match any string matching the specifications outlined in question 1. If the egrep command were entered on Blue, it would work as expected without syntax errors.
Satisfactory
0.42 points

Student defined a regular expression but there is one logical error with the expression which prevents it from matching the input specified in question 1. There are no syntax errors with the command if it were entered on Blue.
Needs Improvement
0.3 points

Student defined a regular expression but there are two or three logical errors with the expression which prevents it from matching the input specified in question 1; OR the command contains one or more syntax errors which will cause it to fail if it were entered on Blue.
Below Expectation
0 points

No solution submitted.
0.6 points
Question 2: Proficient
0.6 points

Student noted the correct number of Nissan electric vehicles that are listed in the input dataset. Student also provided a syntactically-correct Unix command that, if entered on Blue, would correctly count the number of Nissan electric vehicles that are listed in the input dataset.
Satisfactory
0.42 points

Student provided a Unix command to count the number of Nissan electric vehicles that are in the dataset but the number reported is incorrect. The Unix command contains one or two logical errors which prevent the correct number from being reported. The Unix command contains no syntax errors and will run on Blue.
Needs Improvement
0.3 points

Student provided a correct count for the number of Nissan electric vehicles that are in the dataset but failed to include the Unix command to generate such input; OR the Unix command (if provided) does NOT report the correct count for the number of Nissan electric vehicles that are in the dataset.
Below Expectation
0 points

No solution submitted.
0.6 points
Question 3: Proficient
0.6 points

Student noted the correct number of Tesla Model 3 electric vehicles that are listed in the input dataset. Student also provided a syntactically-correct Unix command that, if entered on Blue, would correctly count the number of Tesla Model 3 electric vehicles that are listed in the input dataset.
Satisfactory
0.42 points

Student provided a Unix command to count the number of Tesla Model 3 electric vehicles that are in the dataset but the number reported is incorrect. The Unix command contains one or two logical errors which prevent the correct number from being reported. The Unix command contains no syntax errors and will run on Blue.
Needs Improvement
0.3 points

Student provided a correct count for the number of Tesla Model 3 electric vehicles that are in the dataset but failed to include the Unix command to generate such input; OR the Unix command (if provided) does NOT report the correct count for the number of Tesla Model 3 electric vehicles that are in the dataset.
Below Expectation
0 points

No solution submitted.
0.6 points
Question 4: Proficient
0.6 points

Student noted the correct number for the greatest distance a battery electric vehicle (BEV) can travel regardless of vehicle make. Student also included a syntactically-correct Unix command that, if entered on Blue, would report the correct number for the greatest distance a battery electric vehicle can travel, regardless of vehicle make.
Satisfactory
0.42 points

Student noted an incorrect number for the greatest distance a battery electric vehicle (BEV) can travel regardless of vehicle make. Student provided a syntactically-correct Unix command, that if entered on Blue, would report a number for the greatest distance a battery electric vehicle can travel but the Unix command contains one or two logical errors which prevent it from generating the correct answer.
Needs Improvement
0.3 points

Student noted correct number for the greatest distance a battery electric vehicle (BEV) can travel regardless of vehicle make but failed to include the Unix command to generate such a result; OR the Unix command (if provided) does NOT report the correct distance that a battery electric vehicle can travel, regardless of vehicle make.
Below Expectation
0 points

No solution submitted.
0.6 points
Question 5: Proficient
0.6 points

Student listed all of the the distinct manufacturers that begin with the letter "L". Student also provided the syntactically-correct Unix command that, if entered on Blue, would correctly report all distinct manufacturers that begin with the letter "L".
Satisfactory
0.42 points

Student listed some of the manufacturers that begin with the letter "L" but the list is incomplete. Student also provided the syntactically-correct Unix command that, if entered on Blue, reports these results. The Unix command contains one or two logical errors that prevent the command from reporting all of the manufacturers that begin with the letter "L".
Needs Improvement
0.3 points

Student correctly listed all of the the distinct manufacturers that begin with the letter "L" but failed to include the Unix command to generate such a list; OR the student provided a Unix command which does not correctly identify all of the distinct manufactures that begin with the letter "L".
Below Expectation
0 points

No solution submitted.
0.6 points
Total points: 3