From your description it sounds like you're using regular expressions to convert from vim-style REs to perl-style REs. What you really need is a parser that groks vim-style REs from which you can output the appropriate perl-style REs.

BTW, \& isn't a nightmare, you need to turn A\&B\&C into (?=A)(?=B)C. Though now that I think about it for more than 2 seconds, I suppose the "consumption" of the string would have to be nailed down. My version always consumes enough of the string to match the last pattern and I can see arguments for consuming the minimum or maximum of any of the patterns.

Anyway, you need a real parser. Some things weren't meant to be grokked by regular expressions :)


In reply to Re: Converting vim regex to Perl regex by duff
in thread Converting vim regex to Perl regex by lemnisca

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.