Implementation of {is,chop}_{prefix,suffix}.