in reply to Print lines between multi-line regex pattern
Here's another option - read in chunks that end with your ending text.
#!/usr/bin/perl # https://perlmonks.org/?node_id=1216375 use strict; use warnings; $/ = 'APP> END_PARTU_8X8'; while( <DATA> ) { s/.*APP> START_PARTU_8X8\s+APP> PARTITION_SPLIT\n//s or next; /(.*\n)\s*APP> END_PARTU_8X8/s and print $1; } __DATA__ APP> START_PARTU_8X8 APP> PARTITION_NONE START_PARTU_16X16 APP> END_PARTU_8X8 APP> START_PARTU_8X8 APP> PARTITION_SPLIT START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........ APP> END_PARTU_8X8 PARTU_16X4 16X16 4X16 APP> END_PARTU_8X8
Outputs:
START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........ START_PARTU_4X4 ........
There is a conflict between your text description of what you want printed and your output. I went by the text.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Print lines between multi-line regex pattern
by Eshan_k (Acolyte) on Jun 22, 2018 at 00:00 UTC |