Last Updated: February 25, 2016
·
282
· lopsae

Remove line wrapped newlines

Say that your favorite email program/webapp wraps lines at some arbitrary line width.

When you receive a long email and you copy the contents you will end with the text split into several lines.

Paste it into your regex friendly text editor and search for this pattern:

([^\s])\n([^\s])

This will search for all lines that contain any letter or symbol (any not whitespace character) followed by a newline followed by another letter or symbol. Any lone newlines will not be matched by this pattern, and thus will be left untouched.

Now And replace with:

\1 \2

Which will grab the match in the first parenthesis of the pattern (the last character in each line), the second parenthesis (the first character of the next line) and put a space in between those, instead of the newline.