The need for a regex solution is as you surmise, partially arbirtrary (no, I'm not doing homework, it's been 15+ years since I had any to do). The problem is that this particular problem is only a small portion of something I'm trying to solve as part of a large regex. I have considered other non-regex solutions, and I may end up returning to them, but there will be certain grace to solving the "big problem" with regex if practical.

As for inefficiency, the question becomes "how inefficient?". While what I hope to do is construct a "very massive" regex, If it can be applied to a 2K string and resolved in under a minute on single processer Intel box, that's probably fast enough for my purposes. (I realize that the question "How inefficient? is difficult to answer without a far better understanding of the entire pattern and the input, but I thought I'd ask anyway :)

I've never used lookaheads, so I'll have to "do some research" to understand your example.

Thanks.

In reply to RE: Re: Set theory in regexs by dcorbin
in thread Set theory in regexs by dcorbin

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.