develooper Front page | perl.perl5.porters | Postings from July 2013

Re: [perl #119095] Empty regular expression does not match in somecases

Thread Previous | Thread Next
From:
Petr Pisar
Date:
July 31, 2013 15:20
Subject:
Re: [perl #119095] Empty regular expression does not match in somecases
Message ID:
slrnkviao7.456.ppisar@dhcp-0-146.brq.redhat.com
On 2013-07-31, Paul Johnson <paul@pjcj.net> wrote:
>
> I think this is one of those "it's a feature, not a bug" moments.
> Though I'll admit that in over 20 years of using Perl, it's a feature
> I've never made use of.
>
> From perlop:
>
>     The empty pattern //
>             If the PATTERN evaluates to the empty string, the last
>             successfully matched regular expression is used instead. In this
>             case, only the "g" and "c" flags on the empty pattern are honored;
>             the other flags are taken from the original pattern. If no match
>             has previously succeeded, this will (silently) act instead as a
>             genuine empty pattern (which will always match).
>
I see. Then it's a feature. Never mind.

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.

-- Petr


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About