trimMargin

Trims leading whitespace characters followed by marginPrefix from every line of a source string and removes the first and the last lines if they are blank (notice difference blank vs empty).

fun String.trimMargin(marginPrefix: String = "|"): String(source)
val text = """
    |Hello, world!
    |  This line is indented.
    |Goodbye, world!
""".trimMargin()

println(text)

Source