My question I'm sure could have been phrased better. Basically what I was thinking is there are certain times when you might want to use an expression without requiring the module. (Normally I would just want to stick with "use"ing it and getting the benefit of the module's maintainence), so I was curious if there was a way to go from a compiled expression to something I could add to a script without requiring the module for the one regex.

A simple example but if I wanted a pattern to match a real but didn't want to require Regexp::Common I could do something like this.
#!/usr/bin/perl use warnings; use strict; use Regexp::Common qw/number/; use YAPE::Regex::Explain; print YAPE::Regex::Explain->new($RE{num}{real})->explain(); __END__ The regular expression: (?-imsx:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?: +[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|) +)) matches as follows: NODE EXPLANATION ------------------------------------------------------------BLAH BLAH +BLAH
and just add
$thing=~/(?-imsx:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789 +]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456 +789]+))|))) /
to my code.

Which seems like it works but as regex's are my weakest Perl strength, I didn't know if this is a any caveats (things known not to work) with this approach or if there is a more reliable way of doing it. Obviously "cutting and pasting" is a bad idea without total understanding is in general though as far as regexes, I'm willing to put stock in a few monks work (yourself included), but I didn't know if there was anything inherently wrong with the approach.

-Lee

"To be civilized is to deny one's nature."

In reply to Re: Re: Decompiling Regular Expressions by shotgunefx
in thread Decompiling Regular Expressions by shotgunefx

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.