for word in segment:
if r.match(word) is not None:
words = word.split("-")
words.insert(1, "////AT////-////AT////")
new_segment.extend(words)
else:
new_segment.append(word)
return new_segment
After Change
new_segment = []
for word in segment:
if r.match(word) is not None:
words = ["////AT////-////AT////" if w == "-" else w for w in re.split("(-)", word)]
new_segment.extend(words)
else:
new_segment.append(word)