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


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

I'm kinda wondering about this one. Since you know the structure of the data (ie. the data starts after delimiter 'a' and ends with delimter 'b') and you allow the key word to be a regular word in the data I would have to assume your the $text in chromatics answer means that you have all the text in the same string. As I recall, sorry I've lost my mastering regular expressions book, its in Japan with Sawako, you need a regular expression that treats the newline charactor as an embeded charactor rather than the end of a line.

/start(.*)end/s; #rather than /start(.*)end/; #used like this $file = 'C:\fixthis.txt'; open(SESAME, $file); while(<SESAME>) { $text .= $_; } close(SESAME); print $text; $text=~/\n*$//;#get rid of trailing newlines $text=~m/^start(.*)end$/s; print $1; ########the file has this data ########## # I inserted alot of the words start and end to test it. #start #this is the start house startthat jackstart built #and i am end my fathers endchild #all end good boys do finend #and i eat end more chicken than any man that you have seen #end #############the out put is this############# #this is the start house startthat jackstart built #and i am end my fathers endchild #all end good boys do finend #and i eat end more chicken than any man that you have seen
That seems to work ok, if i understood the structure of your data correctly. If not im sure you could modify the regular expression to fit your needs.

Remember, simple is better.

little_mistress@mainhall.com