in reply to Can qr be un-compiled?

It stringifies to a pattern.

>perl -le"print qr/abc/" (?-xism:abc)

Note that JavaScript and Perl's regexp languages differ.

Update: Added example

Replies are listed 'Best First'.
Re^2: Can qr be un-compiled?
by cosmicperl (Chaplain) on Feb 03, 2009 at 13:35 UTC
    my $cregexp = qr/[a-z].*?[0-9] $/is; print $cregexp; prints: (?si-xm:[a-z].*?[0-9] $)
    JavaScript doesn't understand regexps that look like that:-
    http://docs.sun.com/source/816-6408-10/regexp.htm


    Lyle
    -Update: ikegami's original response didn't have an example, hence mine.
    ikegami - It would be nice if you listed updates you make to your replies

      I don't immediately have the means of converting a Perl regexp pattern into a JavaScript regexp pattern, but I got you half way there by answering your question. "[a-z].*?[0-9] $" would not be equivalent to the compiled regexp.

      If you're dealing with the subset that's compatible to both, why don't you just keep the pattern and the compiled regexp separately?

      my %regexps = map { $_ => qr/$_/ } @regexps;
        The problem is I'm dealing with someone else's compiles regexps that are passed to me, so I don't have the original string :(