Return to lecture notes index
September 17th, 2008 (Recitation 4)

In recitation today we discussed some of the most commom mistakes in Lab 1, and we went over the practice exam from lecture in Tuesday. We solved several of the questions in class, here are their solutions. To the get the full questions or the rest of the solutions please contact a TA.

Provide a regular expression that will match a social security number


Translating Wean Hall Room Numbers

		sed -r 's/Wean ([1-8][0-6][0-9]{2})([^0-9]|$)/WeH \1/g'

Match floating point decimal numbers


Note: Please notice that this will not match 7. or .7, it requires there to be at least one number on both sides of the decimal, thus you would have to write 0.7 or 7.0

Perl program that reads 10 lines and displays FP if they are a floating point and NOT otherwise

		foreach (1..10){
		        $line = ;
		        if($line =~ /[+-]?\d*\.\d+$/) {
		                print "FP\n";
		                 print "NOT\n";