http://www.perlmonks.org?node_id=62683


in reply to How do I extract all text between two keywords like start and end?

$_ = "start this is the start this is another end first end start hell +o start inside of hello end there end"; ($re=$_)=~s/((\bstart\b)|(\bend\b)|.)/${[')','']}[!$3]\Q$1\E${['(',''] +}[!$2]/gs; @$ = (eval{/$re/},$@); print join"\n",@$ unless $$[-1]=~/unmatched/;
  • Comment on Re: How do I extract all text between two keywords like start and end?
  • Download Code