final exam quisten

ITEC345 – Final Exam

Due: End of Day (11:59pm), on November 17th.

Standard Disclaimer: Like any other exam, this is a “solo effort” (collaboration between individual students is not permitted) and the general Student Academic Integrity Policy applies . External resources are to be used for reference purposes only; blatant copying of solutions found on-line (or from other students) could result in receiving a zero for the entire exam.

  • Unless otherwise specified for the Regular Expression questions, you can assume that the expression is being applied to some arbitrary text file where the contents is not known in advance.
  • Unless the question states that you should write a complete program, you should only write the expression and NOT a complete program.

  • All references to “Perl Style” regular expressions simply means that the expression should be written in the form: m/match_pattern/ or s/match_pattern/substitution_pattern/
    (depending on whichever is appropriate).

Note: Much of the text has been “locked” in this document, not as a “security measure”, but to prevent accidental editing or deletion of questions.The area beneath each question should be freely editable and feel free to add to remove space between questions as you need!

  • All three of the languages we studied over the course of the semester (JavaScript, Python, and a little Perl) each have Regular Expression processing capabilities either “built-in” to the core syntax of the language or have Regular expression processing available as a standard/supplied library which can be imported.

  • (2 pts) Show a regular expression that will match any a string of characters which contains any number of occurrences of the letter A (and only the letter A, with no other characters or spaces).
  • (2 pts) Show a regular expression that will match any a string of characters which contains at least on occurrence of the letter A, if it is not either the first character or the last character of the string:
  • (2 pts) Show a regular expression would match only a line with exactly 100 character?
  • (2 pts) Show a regular expression would match all words in a string that begin and end with the same letter? (EXAMPLE STRING: “algebra” matches but “amoebae” does not.)
  • (2 pts) Write a “Perl style” regular expression which would match any line containing adjacent repeated words.For example:
    this is is a line(would match against the expression.)
    this is a line(would NOT match against the expression.)
  • (2 pts) A file consists of nothing but a series of value pairs in the following form username=userid, where username can be any combination of letters and numbers and userid is and any numerical value. Write a “Perl style” regular expression which will swap the username and userid values, so username=userid becomes userid=username.
    (EXAMPLE: abcd1=1234 would become 1234=abcd1)
  • (2 pts) Write a “Perl style” regular expression that would search/replace all occurrences of 10 consecutive digits in a string (only 10, no more no less; e.g., 1234567890) in a string with the exact same digits in the following format: 123-456-7890

  • (5 pts) Using regular expressions, write a complete Perl script that, when given input from a file as shown in the sample as shown below, displays ONLY the valid phone numbers found anywhere in the file.For this example, assume a phone number is valid only if it is in the following – rather unusual – form (where 9 represents any number):[999]-999-9999

    Sample Input:
  • (2 pts) Show all of the words with 15 or more letters in the word.
  • (2 pts) Show the count of the number of occurrences of the word “Alice” in the file.
  • (2 pts) Show the line of the file containing the greatest number of occurrences of the word “Alice”.
  • (2 pts) List/show all of the URL’s (http: or https:) in the file.
  • (2 pts) Eliminate/remove/exclude all lines containing only asterisks from the file.
  • (2 pts) List/show all the phrases that appear between single quotes. Note that apostrophes and single quotes use the same character ()
  • (2 pts) Which language(s) have regular expression evaluation integrated into the syntax of the language.
  • (2 pts) Which language(s) require the import of additional “regular expression” library, before regular expression searching/matching/substitution can be use.

For the following questions, which you have write a regular expression, ONLY the expression and nothing but the expression is needed.Complete “functions” are not necessary, nor should they be included as part of the answer.For convenience you may assume that any “new-line” makers are never “consumed” as part of a match and the can be safely ignored.

Pattern Matching


For Example:

Search String:Here are some numbers 123456780 which match.

Becomes: Here are some numbers 123-456-7890 which match.

Search String: Here are some numbers 1234454956780 which do not match.

Stays: Here are some numbers 1234454956780 which do not match.

this is a test
My number: [123]-555-1212
Not a phone number: [123]-5555-1212
test 9999 test.
A phone number ([123]-999-0000) exists on this line.
There is no phone number ({123]-999+0000) on this line.

Sample Output:


Alice Adventures in Wonderland.

For each of the following, use the alice.txt file which is attached to this “Assignment” in Blackboard.Though you must use “Regular Expressions” in some manner to arrive at the solution, you may use either Perl or Python for the “code portion” of the answer.

Show the regular expression (or complete code where applicable) to determine each of the following:

Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.