Hi to all good monks! I have small regexp question, my txt file looks like:
-- 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.


In reply to Regexp help, multiple lines by 2ge

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.