Skip Menu |

This queue is for tickets about the Regexp-Common CPAN distribution.

Report information
The Basics
Id: 104353
Status: resolved
Priority: 0/
Queue: Regexp-Common

People
Owner: Nobody in particular
Requestors: kaoru [...] slackwise.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2013031301
Fixed in: (no value)



Subject: num roman not greedy unless anchored?
This confused me... $ perl -MRegexp::Common=number -E 'for (@ARGV) { if (m/$RE{num}{roman}{-keep}/) { say "Found: $1"; } else { say "No Roman Found" }; };' I II III IV IIII Found: I Found: II Found: III Found: I Found: III Seems that if I anchor the regular expression with ^ and $ then it works. $ perl -MRegexp::Common=number -E 'for (@ARGV) { if (m/^$RE{num}{roman}{-keep}$/) { say "Found: $1"; } else { say "No Roman Found" }; };' I II III IV IIII Found: I Found: II Found: III Found: IV No Roman Found I've attached a more comprehensive test case. Is this expected?
Subject: regexp_common_num_roman_not_greedy.t
use strict; use warnings; use Test::More; use Regexp::Common qw/number/; note 'with ^ and $ anchors'; for my $roman (qw(I II III IV V VI VII VIII IX X)) { if ($roman =~ m/^$RE{num}{roman}{-keep}$/) { is $roman, $1, "$roman => $1"; } } note 'without ^ and $ anchors'; for my $roman (qw(I II III IV V VI VII VIII IX X)) { if ($roman =~ m/$RE{num}{roman}{-keep}/) { is $roman, $1, "$roman => $1"; } } note 'with ^ anchor only'; for my $roman (qw(I II III IV V VI VII VIII IX X)) { if ($roman =~ m/^$RE{num}{roman}{-keep}/) { is $roman, $1, "$roman => $1"; } } note 'with $ anchor only'; for my $roman (qw(I II III IV V VI VII VIII IX X)) { if ($roman =~ m/$RE{num}{roman}{-keep}$/) { is $roman, $1, "$roman => $1"; } } done_testing();
This has been fixed in version 2016052804.