in reply to Greedy flip flop operator?
#!/usr/bin/perl # http://perlmonks.org/?node_id=1213573 use strict; use warnings; #print join('', <DATA>) =~ /^start.*\n(?:\+.*\n)*/gm; # my preference +:) while(<DATA>) { /^start/ .. /^(?!start|\+)/ and /^(start|\+)/ and print; } __DATA__ ignore this line :) start text + 123 + 456 + 789 some other text not starting with + another test case start text + foo + bar start text + one + two + three also ignore this line
Outputs:
start text + 123 + 456 + 789 start text + foo + bar start text + one + two + three
|
|---|