Matching points in compositions and words