I would like to remove any single letter from a string in python.
For example:
input: \'z 23rwqw a 34qf34 h 343fsdfd\' output: \'23rwqw 34qf34 343fsd
import re text = "z 23rwqw a 34qf34 h 343fsdfd" print re.sub(r'(?:^| )\w(?:$| )', ' ', text).strip()
or
tmp = re.sub(r'\b\w\b', ' ', input) print re.sub(r'\s{2,}', ' ', tmp).strip()