use strict;
use warnings;
-our $VERSION = "0.17";
+our $VERSION = "0.18";
our @ISA = qw(Exporter);
our @EXPORT_OK = ('regmust',
qw(is_regexp regexp_pattern
} elsif ($s =~ s/^\///) {
my $reflags = $^H{reflags} || 0;
my $seen_charset;
- while ($s =~ m/( aa | . )/gx) {
+ while ($s =~ m/( . )/gx) {
$_ = $1;
if (/[adul]/) {
+ # The 'a' may be repeated; hide this from the rest of the
+ # code by counting and getting rid of all of them, then
+ # changing to 'aa' if there is a repeat.
+ if ($_ eq 'a') {
+ my $sav_pos = pos $s;
+ my $a_count = $s =~ s/a//g;
+ pos $s = $sav_pos - 1; # -1 because got rid of the 'a'
+ if ($a_count > 2) {
+ require Carp;
+ Carp::carp(
+ qq 'The "a" flag may only appear a maximum of twice'
+ );
+ }
+ elsif ($a_count == 2) {
+ $_ = 'aa';
+ }
+ }
if ($on) {
if ($seen_charset) {
require Carp;
.qq 'are exclusive'
);
}
- elsif ($seen_charset eq 'a') {
- Carp::carp(
- qq 'The "a" flag may only appear twice if '
- .qq 'adjacent, like "aa"'
- );
- }
else {
Carp::carp(
qq 'The "$seen_charset" flag may not appear '
use strict;
-use Test::More tests => 58;
+use Test::More tests => 53;
-my @flags = qw( a d l u aa );
+my @flags = qw( a d l u );
use re '/i';
ok "Foo" =~ /foo/, 'use re "/i"';
}
no re '/x';
+# Verify one and two a's work
+use re '/ia';
+is qr//, '(?^ai:)', 'use re "/ia"';
+no re '/ia';
+is qr//, '(?^:)', 'no re "/ia"';
+use re '/aai';
+is qr//, '(?^aai:)', 'use re "/aai"';
+no re '/aai';
+is qr//, '(?^:)', 'no re "/aai"';
+
# use re "/adul" combinations
{
my $w;
}
$w = "";
- eval "use re '/axa'";
- like $w, qr/The "a" flag may only appear twice if adjacent, like "aa"/,
- "warning with eval \"use re \"/axa\"";
+ eval "use re '/axaa'";
+ like $w, qr/The "a" flag may only appear a maximum of twice/,
+ "warning with eval \"use re \"/axaa\"";
}