示例:
string = " a lot of text ... protective equip- ment ... a lot of text - with similar broken words like simple appli- cations ..."
我需要获得相同的文本,但设备变成设备,而应用程序变成应用程序。谢谢
尝试一下:
>>> import re
>>> string = " a lot of text ... protective equip- ment ... a lot of text - with similar broken words like simple appli- cations ..."
>>> re.sub(r"(\w+)- (\w+)", r"\1\2", string)
' a lot of text ... protective equipment ... a lot of text - with similar broken words like simple applications ...'