in reply to How regex works here?

In contrast, consider matching and deleting only that which you wish to eliminate from the string:
>perl -wMstrict -le "my $line = 'B6y green $1$Byf3501d$dPtaW2vCbq63sdsw'; $line =~ s{ \s \S+ $ }{}xms; print qq{'$line'}; " 'B6y green'