Detect similar characters at the end of a line