in reply to Replacing the pattern
Update: Finally grasped the feature that the OP wanted and wasn't getting: In addition to substituting spaces, maintain the same number of lines. Like this:
Output is:$_ =<<'EOS'; </TABLE> 2 <PAGE> RISK/RETURN SUMMARY AND FUND EXPENSES PRIME MONEY MARKET FUND EOS my $pat = qr/(\n\s*[0-9]{1,3}\s*\n\s*<page>\s*\n\s*)(.*\n)/i; s{$pat}{ my ($m1, $m2) = ($1, $2); my $num_lines = $m1 =~ tr/\n//; # Just counting lines $m1 =~ tr//!/c; # Replacing all chars with ! (for visibility; use sp +ace instead in final code) $m1 . $m2 . "\n" x $num_lines; }gie or warn "No match!\n"; print;
</TABLE>!!!!!!!!!!!!RISK/RETURN SUMMARY AND FUND EXPENSES PRIME MONEY MARKET FUND
|
|---|