Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am having some problems with pattern matching.
I need to generate some perl that searches through an html document to find snippets of text delimited by two strings, and to assign anything between these two delimiting strings to an array.
The snippets of text are spread over 4 lines.
The opening delimiter is <!-- Start_of_revision--> on the first line, and the closing delimiter is <!-- End_of_revision-->, on the fourth line.
There can multiple instances of this 4-line snippet in an html document, and each time I detect one of these instances, I would like to put anything between the delimiters into an array, thus building up a list of revisions.
I have tried:
@revision_array=(); if (m/<!-- Start_of_revision-->(.+)<!-- End_of_revision-->/mg) { push (@revision_array, $1); }
But alas, nothing is detected. I'm guessing this is a hopelessly naive approach, but I really haven't got the time to work it out myself, so I was wondering if you guys could help me out?
C J
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pattern matching
by ikegami (Patriarch) on Jul 18, 2005 at 17:13 UTC | |
|
Re: pattern matching
by halley (Prior) on Jul 18, 2005 at 17:16 UTC | |
|
Re: pattern matching
by JediWizard (Deacon) on Jul 18, 2005 at 17:18 UTC | |
|
Re: pattern matching
by cmeyer (Pilgrim) on Jul 18, 2005 at 17:48 UTC | |
|
Re: pattern matching
by mvaline (Friar) on Jul 18, 2005 at 17:26 UTC |