W3cubDocs

/Kotlin

removeSurrounding

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.removeSurrounding(
    prefix: CharSequence, 
    suffix: CharSequence
): CharSequence

When this char sequence starts with the given prefix and ends with the given suffix, returns a new char sequence having both the given prefix and suffix removed. Otherwise returns a new char sequence with the same characters.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String.removeSurrounding(
    prefix: CharSequence, 
    suffix: CharSequence
): String

Removes from a string both the given prefix and suffix if and only if it starts with the prefix and ends with the suffix. Otherwise returns this string unchanged.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.removeSurrounding(
    delimiter: CharSequence
): CharSequence

When this char sequence starts with and ends with the given delimiter, returns a new char sequence having this delimiter removed both from the start and end. Otherwise returns a new char sequence with the same characters.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun String.removeSurrounding(delimiter: CharSequence): String

Removes the given delimiter string from both the start and the end of this string if and only if it starts with and ends with the delimiter. Otherwise returns this string unchanged.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/remove-surrounding.html