Due to some legacy standard when you send an email from Outlook the plain text format includes a CRLF or \r\n every n-characters.
In the app I’m writing I’d like to display this plain text without the added line breaks, so that text wrapping works and I can take full advantage of the screen size.
Outlook, for example, removes these “unnecessary” line break automatically, and I’m trying to write a regex to do the same but struggling with the format.
From what I can tell outlook does its parsing as follows:
- Removes CRLF only on lines with text which does not have a
' '(\s) at the end prior to theCRLF.
Assistance on how to parse this in regex would be greatly appreciated.
That will match a single whitespace character at the end of the line which is not preceeded by a space. Note that you need to have the multiline flag in your regex, or this will only match at the end of the total string.