trim

@JvmName(name = "trimFieldReceiver")
open fun <Context : Any> Field<Context, String?>.trim(): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiver")
open fun <Context : Any> KProperty1<Context, String?>.trim(): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiver")
inline fun String?.trim(): Value<Any, String?>(source)

Removes whitespace characters, including null, or the specified characters from the beginning and end of a string.

By default, removes whitespace characters including the null character.

Example

class Document(
val text: String,
)

collection.aggregate()
.set {
Document::text set of(Document::text).trim()
}.toList()

External resources


open fun <Context : Any> Value<Context, String?>.trim(vararg characters: Char): Value<Context, String?>(source)
@JvmName(name = "trimFieldReceiver")
open fun <Context : Any> Field<Context, String?>.trim(vararg characters: Char): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiver")
open fun <Context : Any> KProperty1<Context, String?>.trim(vararg characters: Char): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiver")
inline fun String?.trim(vararg characters: Char): Value<Any, String?>(source)

Removes the specified characters from the beginning and end of a string.

Example

class Document(
val text: String,
)

// Trim both 'g' and 'e' characters from the beginning and end
collection.aggregate()
.set {
Document::text set of(Document::text).trim('g', 'e')
}.toList()

// Trim space, 'g', and 'e' characters from the beginning and end
collection.aggregate()
.set {
Document::text set of(Document::text).trim(' ', 'g', 'e')
}.toList()

External resources


@JvmName(name = "trimByField")
open fun <Context : Any> Value<Context, String?>.trim(characters: Field<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimByProperty")
open fun <Context : Any> Value<Context, String?>.trim(characters: KProperty1<Context, String?>): Value<Context, String?>(source)
inline fun <Context : Any> Value<Context, String?>.trim(characters: String?): Value<Context, String?>(source)
@JvmName(name = "trimFieldReceiverByValue")
open fun <Context : Any> Field<Context, String?>.trim(characters: Value<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimFieldReceiverByField")
open fun <Context : Any> Field<Context, String?>.trim(characters: Field<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimFieldReceiverByProperty")
open fun <Context : Any> Field<Context, String?>.trim(characters: KProperty1<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimFieldReceiverByResult")
inline fun <Context : Any> Field<Context, String?>.trim(characters: String?): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiverByValue")
open fun <Context : Any> KProperty1<Context, String?>.trim(characters: Value<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiverByField")
open fun <Context : Any> KProperty1<Context, String?>.trim(characters: Field<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiverByProperty")
open fun <Context : Any> KProperty1<Context, String?>.trim(characters: KProperty1<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimPropertyReceiverByResult")
inline fun <Context : Any> KProperty1<Context, String?>.trim(characters: String?): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiverByValue")
inline fun <Context : Any> String?.trim(characters: Value<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiverByField")
inline fun <Context : Any> String?.trim(characters: Field<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiverByProperty")
inline fun <Context : Any> String?.trim(characters: KProperty1<Context, String?>): Value<Context, String?>(source)
@JvmName(name = "trimResultReceiverByResult")
inline fun String?.trim(characters: String?): Value<Any, String?>(source)

Removes the specified characters from the beginning and end of a string.

The characters parameter is a single string that can contain multiple characters to be trimmed. Each character in the string will be removed from both the beginning and end of the input string.

Example

class Document(
val text: String,
)

// Trim both 'g' and 'e' characters from the beginning and end
collection.aggregate()
.set {
Document::text set of(Document::text).trim(chars = of("ge"))
}.toList()

// Trim space, 'g', and 'e' characters from the beginning and end
collection.aggregate()
.set {
Document::text set of(Document::text).trim(chars = of(" ge"))
}.toList()

External resources