Raku's regexes are expected to match longest token.
And in fact, this behaviour is seen in this code:
raku -e "'AA' ~~ m/A {say 1}|AA {say 2}/"
# 2
However, when the text is in a variable, it does not seem to work in the same way:
raku -e "my $a = 'A'; my $b = 'AA'; 'AA' ~~ m/$a {say 1}|$b {say 2}/"
# 1
Why they work in a different way? Is there a way to use variables and still match the longest token?