Sale!

Lab 6: Regular Expressions

$30.00

Category:
Rate this product

CSL202: PROGRAMMING PARADIGMS & PRAGMATICS

Lab 6: Regular Expressions
 Aim: The goal of this lab is to introduce Regular Expressions
 Let’s get started!
o Create a directory structure to hold your work for this course and all the subsequent labs:
 Suggestion: CSL202/Lab6
 Introduction
o Intro to Regular Expressions: This file provides a short crash course on Regular Expressions. It is suggested that
you read the file carefully to understand the basics.
o Perl RegExp Tutorial: Having understood the basics, it is time to use them in Perl. This link gives a decent set
of examples to help with regular expressions in Perl. It is STRONGLY suggested that you CODE the examples
from the Part 1: Basics section, especially, ‘Using Regular Expressions in Perl’ part:
 http://perldoc.perl.org/perlretut.html
o Once you are confident about your regular expressions skills, try the following tasks.
 Exercises
o Print all lines in micro.txt that contain the letter v or V along with the count of the number of lines.
(Task1.pl)
 Sample output:
Have a nice exam period said
the brave instructor.
Just before the class voted for the new president
The count is 3.
o Print all lines in micro.txt that contain the word Java or java. Print the count of the number of matching
lines when done. (Task2.pl)
 Sample output:
I like java.
Java is a very interesting.
Too much java can cause excessive hair
Count is 3 lines
o Display a list and a count of all words in micro.txt that have a capital letter someplace between the first
and last letter of the word. (Task3.pl)
 Sample output:
ALMOST
PTA
heLLo
There are 3 words with a capital letters in the middle.
o Print all single words or pairs of words in micro.txt surrounded by double quotes. Do not include words
with an apostrophe or hyphen. (Task4.pl)
 Sample Output:
too far
funny
close call
o Print a list and total count of all words in micro.txt that begin with an “a” and have the same second and
third letter. The case of the letters is to be ignored. (Task5.pl)
 Sample Output:
allow
aLl
alL
Attic
There are 4 words that start with a and have the same 2nd and 3rd character.
o Write a regular expression which matches a 10 digit phone number given in the following formats:
XXXXXXXXXX or XXX XXX XXXX or XXX-XXX-XXXX (RegexPhone.pl). Given a particular string as input, it
should output TRUE or FALSE depending on pattern matching.
o Write a regular expression which matches time of day such as “9.17 am” or “12.30 pm”
(RegexTime.pl). Given a particular string as input, it should output TRUE or FALSE depending on
pattern matching.
 Next Week!
o Regular Expressions exercises in Perl !
 Submitting your work:
o All source files and class files as one tar-gzipped archive.
 When unzipped, it should create a directory with your ID. Example: 2008CSB1001 (NO
OTHER FORMAT IS ACCEPTABLE!!! Case sensitive!!!)
o Source files should include the following: (Case-Sensitive file names!!)
• Task1.pl [2 Points]
• Task2.pl [2 Points]
• Task3.pl [3 Points]
• Task4.pl [3 Points]
• Task5,pl [3 Points]
• RegexPhone.pl [3 Points]
• RegexTime.pl [4 Points]
o Negative marks for any problems/errors in running your programs
o Submit/Upload it to Google Classroom

Lab 6: Regular Expressions
$30.00
Open chat
Need help?
Hello
Can we help?