I have a text file where lines are trimmed by newline characters /n
and paragraphs by double newlines /n/n
I want to strip out those single newlines and replace with simple spaces. But I do not want the double newlines affected.
I thought something like one of these would work:
(?!\n\n)\n
\n{1}
\n{1,1}
But no luck. Everything I try inevitably ends up affecting those double new lines too. How can I write a regex that effectively "ignores" the /n/n
but captures the /n
CodePudding user response:
You can search using this regex:
(.)\n(?!\n)
And replace it with:
"\1 "
Hope this helps. Eager to see other regex answers too! Happy coding