When dealing with text files that have been produced using optical character recognition (OCR) I often come across lines or parts of lines
t h a t a r e s p a c e d o u t l i k e t h i s.
I would like to be able to use a regular expression to match these words and smash the letters back together. But I have no idea how to do this using capture groups or my usual toolbox of regular expression knowledge.
那可能是您要寻找的:
re.sub(r' (.)', r'\1', txt)
尝试这个:
re.sub(r' \b', r'', txt)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.