This is the very issue I was trying to get at recently with my initiatory node validate variable-length lines in one regex?, especially part B. Approach 1 (A or B) is what I was trying to avoid (and, in the end, have had to resort to anyway as this project lacks the time for me to work up any cleverness against it); approach 2 is what I thought might exist and I'm very glad for this exposition; approach 3A seems very excellent and it'll be many projects before I'll have the fluency to attempt anything of the kind.

What my problem had gotten me curious about though was the deeper and much less useful question of whether, in principle, "pure" regex can handle these situations -- whatever "pure" might mean. Solutions 2A and 2B are disqualified because including perl code (or I think any sort of eval?) injects an additional rules-world, patching the incompleteness. I lack the theory to figure out whether 3A's Advanced Features Regex counts as what I'm talking about. I scarcely have the theory to know what I'm talking about.

Everyone else might not care about this; it just brings out the sophomore in me, is all. Seems as though I should look into that Regexp::Grammars. Anyway, thanks very much, smls; I like it.


In reply to Re: Advanced techniques with regex quantifiers by uhClem
in thread Advanced techniques with regex quantifiers by smls

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.