On Tue, May 19, 2015 at 8:16 AM, Abigail via RT <
bug-Regexp-Common@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=104508 >
>
> On Mon, May 18, 2015 at 06:26:48PM -0400, Andreas Nilsson via RT wrote:
> > Mon May 18 18:26:47 2015: Request 104508 was acted upon.
> > Transaction: Ticket created by andrnils@gmail.com
> > Queue: Regexp-Common
> > Subject: Bug in Regexp::Common::net
> > Broken in: (no value)
> > Severity: (no value)
> > Owner: Nobody
> > Requestors: andrnils@gmail.com
> > Status: new
> > Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=104508 >
> >
> >
> > Hello,
> >
> > I've been trying to get Regexp::Common::net to distinguish some possible
> ip
> > address, both ipv4 and ipv6, however I noticed some bugs:
> >
> > while ( <> ) {
> >
> > /$RE{net}{IPv4}/ and print "ipv4\n";
> >
> > }
> >
> >
> > as reg.pl I get
> >
> > $ echo 1.1.1.1 | ./reg.pl
> >
> > ipv4
> >
> > andrnils@tallant:~/Downloads/src 00:19:48 0
> >
> > $ echo 111111111.1.1.1 | ./reg.pl
> >
> > ipv4
> >
> > andrnils@tallant:~/Downloads/src 00:19:53 0
> >
> > $ echo 1111aaa11111.1.1.1 | ./reg.pl
> >
> > ipv4
> >
> > andrnils@tallant:~/Downloads/src 00:21:17 0
> >
> > $ echo 1111aaa1111111111111111111111.1.1.1 | ./reg.pl
> >
> > ipv4
> >
> >
> > Those are not ipv4 address. I think the regexp lacks some specifics,
> > telling to consider the whole input, ie add ^( regexp )\$ to the create
> > lines makes it behave. Seems to be the same for ipv6.
>
>
>
> This is not a bug, this behaviour is intentional.
>
> Each of the examples you give are strings that contain an IP4v4
> address, and hence, the pattern matches.
>
> If you want anchors, you will have to supply them yourselves; not
> just for the IPv4 addresses, but for all the patterns of Regexp::Common.
> If the patterns would be anchored, it would be very hard to
> interpolate them in a larger regular expression.
>
> This is explained in the manual page of Regexp::Common, under the
> section NOT A BUG
>
>
> Regards,
>
>
> Abigail
>
>
Hello,
now that was unexpected. I'll add anchors myself then.
However, while there are ipv4 address in my examples above, where are they
in the following examples:
$ echo 11191.91111.911119.91111 | ./reg.pl
ipv4
$ echo 5555.5555.5555.5555 | ./reg.pl
ipv4
$ echo 1g.1g.1g.1g | ./reg.pl
ipv4
Best regards
Andreas