Skip to content

Commit 1771520

Browse files
committed
Fix offset
1 parent 6d2dfde commit 1771520

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/Data/Random/String/Matches.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,11 @@ sub _parse_sequence {
523523

524524
sub _handle_quantifier {
525525
my ($self, $pattern, $pos, $generator, $check_possessive) = @_;
526+
$check_possessive //= 1; # Default to checking for possessive
526527

527528
my $next = substr($pattern, $pos + 1, 1);
528529
my $is_possessive = 0;
529530

530-
$check_possessive //= 1;
531-
532531
# Check for possessive quantifier (+)
533532
if ($check_possessive && $pos + 2 < length($pattern)) {
534533
my $after_next = substr($pattern, $pos + 2, 1);
@@ -538,7 +537,7 @@ sub _handle_quantifier {
538537
}
539538

540539
if ($next eq '{') {
541-
my $end = index($pattern, '}', $pos + 1);
540+
my $end = index($pattern, '}', $pos + 2);
542541
croak "Unmatched '}'" if ($end == -1);
543542
my $quant = substr($pattern, $pos + 2, $end - $pos - 2);
544543

0 commit comments

Comments
 (0)