replaceIndentByMargin

Common
JVM
JS
Native
1.0
fun String.replaceIndentByMargin(
    newIndent: String = "",
    marginPrefix: String = "|"
): String

(source)

Detects indent by marginPrefix as it does trimMargin and replace it with newIndent.

The lines in the original string can be separated with \r\n (CRLF), \n (LF), or \r (CR) characters, however, the lines in the resulting string will be separated solely with \n (LF) character.

Parameters

marginPrefix - non-blank string, which is used as a margin delimiter. Default is | (pipe character).