in reply to Matching and replacing the minimum string from the tail of the regex
my $starting_line = qr{ ^s [^\n]* \n }xsm; # starts with an 's' my $intervening_line = qr{ [^\n]* \n }xsm; # anything my $ending_line = qr{ e [ ] p \n }xsm; # ends with an 'e p' my $between = 1; my $line = do { local $/; <DATA> }; # slurp all the data $line =~ s{ $start_line ${intervening_line}{$between} $end_line } {}gxsm;
this outputs:
Random String s foo e f blah blah End of file
any closer?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching and replacing the minimum string from the tail of the regex
by Anonymous Monk on Aug 09, 2007 at 01:42 UTC | |
by abitkin (Monk) on Aug 09, 2007 at 14:13 UTC |