Replace string characters (LF) in a string using VB.NET

Obvious does not capture LF characters

foo.Replace(Environment.NewLine, String.Empty)

Doesn't ...

foo.Replace("\r\n", "").Replace("\n", "").Replace("\r", "")

The file itself is a multi-line XML file. Line feed characters before an XML declaration are invalid for a string.

+3
source share
1 answer

VB.NET does not use styles for C styles for CR or LF . In VB, your second example translates to:

foo.Replace(vbNewLine, replaceWith).Replace(vbLF, replaceWith).Replace(vbCR, replaceWith)
+7
source

Source: https://habr.com/ru/post/1736355/


All Articles