There are two general purpose solutions to this. japhy's YAPE::Regex will parse the string representation of your regular expression and return an element tree. You could see about manipulating that or getting your info from that somehow. The thing is though - its parsing regexes which means it isn't pulling directly from perl's actual parsed regex. For that you need MJD's Rx module. The issue with is that when I last looked, it required a patch to the perl interpreter (also supplied). If you need a high fidelity copy of your regex and altering your interpreter is not impossible then this is likely the best route.

Alternatively... you could attempt to capture the output from 'use re "debug"'. I asked about this once at Trapping re 'debug' and all I can come up with is if you throw a single instance of perl interpreter at a regex somewhat like `perl -Mre=debug -e 'qr/.../' 1> /dev/null 2> re.debug.output.txt` and then capture the output from STDERR from that. I've never been able to capture this data from within a perl process - not through redirecting STDERR, tying it or anything.


In reply to Re: Altering regular expression trees by diotalevi
in thread Altering regular expression trees by benizi

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.