As a general case, or as a specific case of just the brackets? If it's a relatively specific case of just brackets, you should be able to adapt String expansion script - I think that my solution in this thread is particularly well-suited to this special case, but you could say I'm biased. :-) Actually, more to the point is that I have a certain tool in my toolbox, and that influences how I see the problem: as a specific type of nail. Think of a callback like this:

my @possibilities = expand_string("A[CT]A[CT]", sub { split //, $_; });
Of course, you'd have to change expand_string to use brackets rather than parenthesis and braces as it does in that node.

For the absolute general case, I would have to say that * and + would kill you. Or at least kill whatever program tried to calculate it. So you'd have to define your minilanguage as a subset of regular expressions that did not include unlimited-length wildcards. Even using the "." character is painful - again, some definition would be required about the actual range of this - you probably don't want all of unicode.

But, it would be an interesting problem to solve - to see what type of limitations would need to be placed on the regular expression to allow for this to allow the regular expression to be solved in this way, and to see the actual solution.


In reply to Re: back translating regular expressions by Tanktalus
in thread back translating regular expressions by anthonywatson

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.