If it's just the flags, you can remove them yourself.
my %on_flags;
my %off_flags = map { $_ => 1 } split //, 'xism';
my $pattern = "$compiled";
if ($pattern =~ /^\(\?([a-z]+)(?:-([a-z])+)?:(.*)\)\z/s) {
(my $on_flags, my $off_flags, $pattern) = ($1, $2||'');
%on_flags = map { $_ => 1 } split //, $on_flagfs;
delete @off_flags{keys %on_flags};
%off_flags = map { $_ => 1 } split //, $off_flags;
delete @on_flags{keys %off_flags};
}
...generate JavaScript code here...
Note: Doesn't handle other features of Perl regexps not present in JavaScript. There's a regexp parser module on CPAN (whose name escapes me) that would be more useful to you if you want to handle more.
Note: Since it expects a compiled pattern, it doesn't handle $compiled = '(?i:foo)bar\)';
|