Log in to users.cs.umb.edu
- Log in to a Windows machine
Enter your Unix username as the account name. Then enter your password.- Run the ssh client
Use the values in the table below to connect to users.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host users.cs.umb.edu user name your unix username Authentication method password - Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.- Make sure you are in your home directory
cd- Go to your it441 directory
cd it441- Go to your ex directory
cd ex- Create an ex13 directory
mkdir ex13- Go to your ex13 directory
cd ex13- Execute the script command
script- Use your perlsession alias to start the re.pl script.
perlsession(NOTE: If the perlsession alias is not recognized, or if re.pl cannot run, then double-check your Perl configuration, as well as your login shell vs. subshell environments!)Regexes - The i option and the . Meta-Character
perl> $string = "foobar" ; perl> if ($string =~ /foo/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /Foo/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /BAR/i) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo.ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /.oo.ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo..ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; }Regexes - The ? Meta-Character
perl> if ($string =~ /foob?ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foobf?ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foob?far/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo.?ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foob.?ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foob.?far/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; }Regexes - The * Meta-Character
perl> if ($string =~ /fo*bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo*bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /fooo*bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foooo*bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foobf*ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo.*bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /f.*ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; }Regexes - The + Meta-Character and Specific Character Counts
perl> if ($string =~ /fo+bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo+bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /fo{2}bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /fo{1,3}bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /fooo+bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foob+ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /foo.+bar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /f.+ar/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /fo+.+r/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; }Regexes - Special Characters and Cases
perl> $string = "3.14159" ; perl> if ($string =~ /3.14/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3214/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3@14/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.14/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ("3214" =~ /3\.14/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.1\d*9/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.1\d+9/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.1\d+/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.[1-5]+9/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; } perl> if ($string =~ /3\.14[13579]+/) { print "Match!\n" ; } else { print "Sorry, no match.\n" ; }End the Perl Session
perl> exitEnd the script session
Use the exit command. You should then have a file called typescript in your current working directory.