String.ReplaceLineEndings

From Xojo Documentation

Method

String.ReplaceLineEndings(replacement As String) As String

Supported for all project types and targets.

Replaces the line endings in the passed String with the specified replacement.

Usage

result = sourceVariable.ReplaceLineEndings(replacementLineEnding)

Part Type Description
result String A copy of sourceVariable with the new line endings replacing the original line endings.
SourceString String The original string.
replacement String The value used to replace the line endings in sourceVariable.

Notes

ReplaceLineEndings does a global search-and-replace for the end of line characters in SourceString using the specified value (replacement) as the replacement string. The search automatically recognizes Windows, macOS, and Unix line endings. Use this function to make multiline (or multi-paragraph) text compatible across platforms. The easiest way to specify the replacement value is with the EndOfLine class.

Sample Code

This example replaces the line endings in the text in a TextField with Windows line endings.

Var s As String
s = TextField1.Value.ReplaceLineEndings(EndOfLine.Windows)

See Also

EndOfLine class.