You provided command works in this way. * mean it print if "a" is just right on next of "p". But if "a" is not just concatenate with "p" on right side, it only print "P".
Terminal