Help for this page

Select Code to Download


  1. or download this
    my $input = "line1\nline2\nline3 foo\nline4\nline5";
    my ($before,$match,$after) = $input=~/^ (?:(.*)\n)? (.*foo.*) (?:\n (?
    +:(.*)\n?)? )? /xm;
    print "before=<$before>, match=<$match>, after=<$after>\n";