use v5.14; say "With the ?"; 'AATCGTTGAATGCAATGACATGAC' =~ / (\w\w\w)*? (?=(?{say "Checking if <$&> is followed by TGA"})) # Print everything that matched before that point TGA/x; say "Match: $&"; say "\nWithout the ?"; 'AATCGTTGAATGCAATGACATGAC' =~ / (\w\w\w)* (?=(?{say "Checking if <$&> is followed by TGA"})) # Print everything that matched before that point TGA/x; say "Match: $&";