On Wed Jul 31 08:34:08 2013, zefram@fysh.org wrote: > Petr Pisar wrote: > >Just if you want to know my use case, the second match uses a regular > >expression specified by an user. And user could assume that an empty > >expression matches any string. > > To provide consistent semantics to the user, you need to process the > user-supplied regexp, by something like > > $perlre = $userre eq "" ? qr/(?:)/ : qr/$userre/; > > or > > $perlre = qr/(?:$userre)/; > > (Compiling the regexp early with qr// is often a good idea.) Watch out for qr/$userre/. I fixed that in perl 5.18 (commit 6a97c51d3ccb), but in earlier perls qr// would trigger the same behaviour. In 5.18+ qr/$userre/ will work as expected (like /(?:)/) with empty patterns. -- Father Chrysostomos --- via perlbug: queue: perl5 status: resolved https://rt.perl.org:443/rt3/Ticket/Display.html?id=119095Thread Previous | Thread Next