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
[0-9]{3}-[0-9]{2}-[0-9]{4}
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
[+-]?[0-9]+\.[0-9]+
Perl program that reads 10 lines and displays FP if they are a floating point and NOT otherwise
#!/usr/bin/perl foreach (1..10){ $line =; if($line =~ /[+-]?\d*\.\d+$/) { print "FP\n"; }else{ print "NOT\n"; } }