I have the following sentence:
sentence = "Work \nExperience \n\n First Experience..."
Work
Experience
First Experience...
So, I want to remove the "\n" between Work and Experience, but at the same time I don't want remove "\n\n" after Experience.
Work Experience
First Experience...
I've tried different solution like:
string = re.sub(" \n{1}[^\n]"," ",sentence)
but all of them remove the first character after \n (E).
Update: I managed to find the solution thanks to @Wiktor
print(re.sub(r'\w .*?\w+', lambda x: x.group().replace('\n', ''), sentence, flags=re.S))