counting segments of string by delimiter