Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Answer: How do I extract all text between two keywords like start and end?

( #26408=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How do I extract all text between two keywords like start and end? - Answer contributed by Anonymous Monk

Hi guys. This seems to work. I'd like some comments on this. I'm trying to further my perl education. Thanks. -Ty
$line = "start this is the start this is another end first end start h +ello start inside of hello end there end"; while ($line=~ s/\s*\bstart\b(?!.*?\bstart\b) (.+?) \bend\b//) { print $1, "\n"; }
tkroll@hawaii.edu

  • Comment on Answer: How do I extract all text between two keywords like start and end?
  • Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2016-08-29 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (398 votes). Check out past polls.