in reply to Regular expression to English translation

Perhaps japhy's YAPE::Regex::Explain is what you're after e.g
use YAPE::Regex::Explain; print YAPE::Regex::Explain->new(qr/this.*(?:that)?(?!another)/) ->explain; __output__ The regular expression: (?-imsx:this.*(?:that)?(?!another)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- this 'this' ---------------------------------------------------------------------- .* any character except \n (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- (?: group, but do not capture (optional (matching the most amount possible)): ---------------------------------------------------------------------- that 'that' ---------------------------------------------------------------------- )? end of grouping ---------------------------------------------------------------------- (?! look ahead to see if there is not: ---------------------------------------------------------------------- another 'another' ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Regular expression to English translation
by Wassercrats (Initiate) on Nov 27, 2003 at 12:33 UTC
    My fear is that that's the best that could be done. I haven't completely thought through how practical what I want is, but I would need something more like a list of expressions that match with no reference to regex code.
      Then the likes of Parse::RandGen are probably worth looking at. Here's some sample usage
      use Parse::RandGen; my $p = Parse::RandGen::Regexp->new(qr/a(b|c)d?/); print $p->pick for 1 ..5 __output__ abd ab ac acd abd
      HTH

      _________
      broquaint

        That looks promising! Unfortunately, that particular Parse:: module isn't available on my web host's server, and it looks like ActivePerl doesn't come with any Parse:: modules. I might be able to get it installed on one or the other though. I'll take a closer look when I get a chance and am fully awake. Thanks