It may be that there’s some extra whitespace between the EndOfLines that prevents the ReplaceAll from working. You could try this:
Function CompressEndOfLine(s1 As String) as String
'Removes duplicate EndOfLine characters from text.
'Also trims leading and trailing whitespace.
dim s As String =s1
'Convert all tabs into spaces
dim L As Integer = len(s)+1
'Replace duplicate line endings (with included spaces) repeatedly until length stops changing
To expand on Weaver’s code using RegEx. Possibly more robust. Deals with other whitespace such as TAB. Try to deal with the various line endings that might be in the original text possibly pasted from some weird source.
As a side issue Tim, what does the problematic text look like in a text editor such as BBEdit where you can optionally “see” the “invisible” characters?
I suspect that you do not have to enclose all this in the
[code]While Len(curedString) <> L
but you could test this. Anyway, below is the suggested code.
[code]Public Function CompressEndOfLine(s1 As String) as String
Dim curedString As String = s1
[quote=371992:@Tim Turner]OK Julian I did that.
The only thing between paragraphs is: %0D%0A[/quote]
I guess if you have single %0D%0A between paragraphs, then your OutputString is Ok.
The only thing I can see from your screencast is that the last line of the paragraph with single space is shorter (only has 5 words that line), while the others that have extra space are longer (at least 7 words). I haven’t learn about printing and formatting so I can’t help with that.