Ah.. okay, I see what you were trying to do. The problem is that's not what the original poster needed - distinguishing by capitalization won't work for his real data set where instead of the wxyz there will be ACGT characters. So you have to try and find consecutive sequences out of
$A in the right order inside
$B, taking into account extra ACGT sequences in
$B.
Makeshifts last the longest.