www.perl.com
Perl Programming
Regular Expressions
  • Perl has several regex modifies
    • g global: allows for multiple substitutions
    • i case insensitive matching
    • s treat string as one line
    • m treat string as multiple lines


      my $breakfast = 'Lox Lox Lox lox and bagels';
      $breakfast =~ s/Lox //g;
      print "$breakfast\n";

      my $paragraph = "First Line\nSecond Line\nThird Line\n";
      my ($first, $second) = ($paragraph =~ /(^.*$)\n(^.*$)/m);
      print "$first, $second\n";
      

      lox and bagels      
      First Line, Second Line
      
Previous http://stuff.mit.edu/iap/perl/