2ge has asked for the wisdom of the Perl Monks concerning the following question:
-- Paragraph1: text Paragraph2: text1 text2 text3 Paragraph3: text --
Ok, now I want extract everything between Paragraph2 and Paragraph3. But I have small problem, I cant use 'Paragraph2:\s+(.*)\s+Paragraph3:/is' because I dont know name of next Paragraph (Paragraph3) - it could be Paragraph1,2,3 and so on... Hint: Name of Paragraph has ':' at end of line, it is five (5) spaces from start of line, extracted text has always nine (9) spaces from start. Any hints on this? It should be nice regexp, if it is possible... (sorry for my poor English and this is my first post here:)
Thanks for any help! (DelimMatch is the solution?)
P.S. My first question has some errors, so I will corect them: Paragraph[123] should be for example 'Name', 'Address', 'City' and so on (many possibilities, sometimes are all not of them shown!) I cant use 'scalar range operator' nor (.*) because I dont know name of end paragraph. Maybe the best solution is not the find "hard regexp", but real names of paragraphs and after create regexp.
Janitored by davido: paragraph tags added to reflect the layout of the text as posted.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp help, multiple lines
by Zaxo (Archbishop) on Aug 15, 2004 at 22:01 UTC | |
|
Re: Regexp help, multiple lines
by davidj (Priest) on Aug 15, 2004 at 22:02 UTC | |
|
Re: Regexp help, multiple lines
by CombatSquirrel (Hermit) on Aug 15, 2004 at 22:02 UTC | |
by 2ge (Scribe) on Aug 15, 2004 at 22:42 UTC | |
by CombatSquirrel (Hermit) on Aug 16, 2004 at 05:34 UTC | |
by 2ge (Scribe) on Aug 16, 2004 at 08:16 UTC | |
|
Re: Regexp help, multiple lines
by ysth (Canon) on Aug 16, 2004 at 00:30 UTC | |
|
Re: Regexp help, multiple lines
by spoulson (Beadle) on Aug 16, 2004 at 20:08 UTC |