Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if all characters match the given predicate.
fun CharSequence.all(predicate: (Char) -> Boolean): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if char sequence has at least one character.
fun CharSequence.any(): Boolean
Returns true
if at least one character matches the given predicate.
fun CharSequence.any(predicate: (Char) -> Boolean): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Creates an Iterable instance that wraps the original char sequence returning its characters when being iterated.
fun CharSequence.asIterable(): Iterable<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Creates a Sequence instance that wraps the original char sequence returning its characters when being iterated.
fun CharSequence.asSequence(): Sequence<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a Map containing key-value pairs provided by transform function applied to characters of the given char sequence.
fun <K, V> CharSequence.associate(
transform: (Char) -> Pair<K, V>
): Map<K, V>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a Map containing the characters from the given char sequence indexed by the key returned from keySelector function applied to each character.
fun <K> CharSequence.associateBy(
keySelector: (Char) -> K
): Map<K, Char>
Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to characters of the given char sequence.
fun <K, V> CharSequence.associateBy(
keySelector: (Char) -> K,
valueTransform: (Char) -> V
): Map<K, V>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each character of the given char sequence and value is the character itself.
fun <K, M : MutableMap<in K, in Char>> CharSequence.associateByTo(
destination: M,
keySelector: (Char) -> K
): M
Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and and value is provided by the valueTransform function applied to characters of the given char sequence.
fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateByTo(
destination: M,
keySelector: (Char) -> K,
valueTransform: (Char) -> V
): M
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each character of the given char sequence.
fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateTo(
destination: M,
transform: (Char) -> Pair<K, V>
): M
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a Map where keys are characters from the given char sequence and values are produced by the valueSelector function applied to each character.
fun <V> CharSequence.associateWith(
valueSelector: (Char) -> V
): Map<Char, V>
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Populates and returns the destination mutable map with key-value pairs for each character of the given char sequence, where key is the character itself and value is provided by the valueSelector function applied to that key.
fun <V, M : MutableMap<in Char, in V>> CharSequence.associateWithTo(
destination: M,
valueSelector: (Char) -> V
): M
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Splits this char sequence into a list of strings each not exceeding the given size.
fun CharSequence.chunked(size: Int): List<String>
Splits this char sequence into several char sequences each not exceeding the given size and applies the given transform function to an each.
fun <R> CharSequence.chunked(
size: Int,
transform: (CharSequence) -> R
): List<R>
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Splits this char sequence into a sequence of strings each not exceeding the given size.
fun CharSequence.chunkedSequence(size: Int): Sequence<String>
Splits this char sequence into several char sequences each not exceeding the given size and applies the given transform function to an each.
fun <R> CharSequence.chunkedSequence(
size: Int,
transform: (CharSequence) -> R
): Sequence<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the longest string prefix
such that this char sequence and other char sequence both start with this prefix, taking care not to split surrogate pairs. If this and other have no common prefix, returns the empty string.
fun CharSequence.commonPrefixWith(
other: CharSequence,
ignoreCase: Boolean = false
): String
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the longest string suffix
such that this char sequence and other char sequence both end with this suffix, taking care not to split surrogate pairs. If this and other have no common suffix, returns the empty string.
fun CharSequence.commonSuffixWith(
other: CharSequence,
ignoreCase: Boolean = false
): String
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence contains the specified other sequence of characters as a substring.
operator fun CharSequence.contains(
other: CharSequence,
ignoreCase: Boolean = false
): Boolean
Returns true
if this char sequence contains the specified character char.
operator fun CharSequence.contains(
char: Char,
ignoreCase: Boolean = false
): Boolean
Returns true
if this char sequence contains at least one match of the specified regular expression regex.
operator fun CharSequence.contains(regex: Regex): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the length of this char sequence.
fun CharSequence.count(): Int
Returns the number of characters matching the given predicate.
fun CharSequence.count(predicate: (Char) -> Boolean): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence with the first n characters removed.
fun CharSequence.drop(n: Int): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence with the last n characters removed.
fun CharSequence.dropLast(n: Int): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given predicate.
fun CharSequence.dropLastWhile(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing all characters except first characters that satisfy the given predicate.
fun CharSequence.dropWhile(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a character at the given index or the result of calling the defaultValue function if the index is out of bounds of this char sequence.
fun CharSequence.elementAtOrElse(
index: Int,
defaultValue: (Int) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a character at the given index or null
if the index is out of bounds of this char sequence.
fun CharSequence.elementAtOrNull(index: Int): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence ends with the specified character.
fun CharSequence.endsWith(
char: Char,
ignoreCase: Boolean = false
): Boolean
Returns true
if this char sequence ends with the specified suffix.
fun CharSequence.endsWith(
suffix: CharSequence,
ignoreCase: Boolean = false
): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence containing only those characters from the original char sequence that match the given predicate.
fun CharSequence.filter(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence containing only those characters from the original char sequence that match the given predicate.
fun CharSequence.filterIndexed(
predicate: (index: Int, Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Appends all characters matching the given predicate to the given destination.
fun <C : Appendable> CharSequence.filterIndexedTo(
destination: C,
predicate: (index: Int, Char) -> Boolean
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence containing only those characters from the original char sequence that do not match the given predicate.
fun CharSequence.filterNot(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Appends all characters not matching the given predicate to the given destination.
fun <C : Appendable> CharSequence.filterNotTo(
destination: C,
predicate: (Char) -> Boolean
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Appends all characters matching the given predicate to the given destination.
fun <C : Appendable> CharSequence.filterTo(
destination: C,
predicate: (Char) -> Boolean
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character matching the given predicate, or null
if no such character was found.
fun CharSequence.find(predicate: (Char) -> Boolean): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Finds the first occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.findAnyOf(
strings: Collection<String>,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Pair<Int, String>?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the last character matching the given predicate, or null
if no such character was found.
fun CharSequence.findLast(
predicate: (Char) -> Boolean
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Finds the last occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.findLastAnyOf(
strings: Collection<String>,
startIndex: Int = lastIndex,
ignoreCase: Boolean = false
): Pair<Int, String>?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns first character.
fun CharSequence.first(): Char
Returns the first character matching the given predicate.
fun CharSequence.first(predicate: (Char) -> Boolean): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character, or null
if the char sequence is empty.
fun CharSequence.firstOrNull(): Char?
Returns the first character matching the given predicate, or null
if character was not found.
fun CharSequence.firstOrNull(
predicate: (Char) -> Boolean
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a single list of all elements yielded from results of transform function being invoked on each character of original char sequence.
fun <R> CharSequence.flatMap(
transform: (Char) -> Iterable<R>
): List<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Appends all elements yielded from results of transform function being invoked on each character of original char sequence, to the given destination.
fun <R, C : MutableCollection<in R>> CharSequence.flatMapTo(
destination: C,
transform: (Char) -> Iterable<R>
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each character.
fun <R> CharSequence.fold(
initial: R,
operation: (acc: R, Char) -> R
): R
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each character with its index in the original char sequence.
fun <R> CharSequence.foldIndexed(
initial: R,
operation: (index: Int, acc: R, Char) -> R
): R
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with initial value and applying operation from right to left to each character and current accumulator value.
fun <R> CharSequence.foldRight(
initial: R,
operation: (Char, acc: R) -> R
): R
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with initial value and applying operation from right to left to each character with its index in the original char sequence and current accumulator value.
fun <R> CharSequence.foldRightIndexed(
initial: R,
operation: (index: Int, Char, acc: R) -> R
): R
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Performs the given action on each character.
fun CharSequence.forEach(action: (Char) -> Unit)
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Performs the given action on each character, providing sequential index with the character.
fun CharSequence.forEachIndexed(
action: (index: Int, Char) -> Unit)
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a character at the given index or the result of calling the defaultValue function if the index is out of bounds of this char sequence.
fun CharSequence.getOrElse(
index: Int,
defaultValue: (Int) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a character at the given index or null
if the index is out of bounds of this char sequence.
fun CharSequence.getOrNull(index: Int): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Groups characters of the original char sequence by the key returned by the given keySelector function applied to each character and returns a map where each group key is associated with a list of corresponding characters.
fun <K> CharSequence.groupBy(
keySelector: (Char) -> K
): Map<K, List<Char>>
Groups values returned by the valueTransform function applied to each character of the original char sequence by the key returned by the given keySelector function applied to the character and returns a map where each group key is associated with a list of corresponding values.
fun <K, V> CharSequence.groupBy(
keySelector: (Char) -> K,
valueTransform: (Char) -> V
): Map<K, List<V>>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Groups characters of the original char sequence by the key returned by the given keySelector function applied to each character and puts to the destination map each group key associated with a list of corresponding characters.
fun <K, M : MutableMap<in K, MutableList<Char>>> CharSequence.groupByTo(
destination: M,
keySelector: (Char) -> K
): M
Groups values returned by the valueTransform function applied to each character of the original char sequence by the key returned by the given keySelector function applied to the character and puts to the destination map each group key associated with a list of corresponding values.
fun <K, V, M : MutableMap<in K, MutableList<V>>> CharSequence.groupByTo(
destination: M,
keySelector: (Char) -> K,
valueTransform: (Char) -> V
): M
Platform and version requirements: JVM (1.1), JS (1.1), Native (1.1)
Creates a Grouping source from a char sequence to be used later with one of group-and-fold operations using the specified keySelector function to extract a key from each character.
fun <K> CharSequence.groupingBy(
keySelector: (Char) -> K
): Grouping<Char, K>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this CharSequence has Unicode surrogate pair at the specified index.
fun CharSequence.hasSurrogatePairAt(index: Int): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the index within this string of the first occurrence of the specified character, starting from the specified startIndex.
fun CharSequence.indexOf(
char: Char,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Int
Returns the index within this char sequence of the first occurrence of the specified string, starting from the specified startIndex.
fun CharSequence.indexOf(
string: String,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Finds the index of the first occurrence of any of the specified chars in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.indexOfAny(
chars: CharArray,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Int
Finds the index of the first occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.indexOfAny(
strings: Collection<String>,
startIndex: Int = 0,
ignoreCase: Boolean = false
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns index of the first character matching the given predicate, or -1 if the char sequence does not contain such character.
fun CharSequence.indexOfFirst(
predicate: (Char) -> Boolean
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns index of the last character matching the given predicate, or -1 if the char sequence does not contain such character.
fun CharSequence.indexOfLast(
predicate: (Char) -> Boolean
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence is empty (contains no characters).
fun CharSequence.isEmpty(): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence is not empty and contains some characters except of whitespace characters.
fun CharSequence.isNotBlank(): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence is not empty.
fun CharSequence.isNotEmpty(): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this nullable char sequence is either null
or empty or consists solely of whitespace characters.
fun CharSequence?.isNullOrBlank(): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this nullable char sequence is either null
or empty.
fun CharSequence?.isNullOrEmpty(): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Iterator for characters of the given char sequence.
operator fun CharSequence.iterator(): CharIterator
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the last character.
fun CharSequence.last(): Char
Returns the last character matching the given predicate.
fun CharSequence.last(predicate: (Char) -> Boolean): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified startIndex.
fun CharSequence.lastIndexOf(
char: Char,
startIndex: Int = lastIndex,
ignoreCase: Boolean = false
): Int
Returns the index within this char sequence of the last occurrence of the specified string, starting from the specified startIndex.
fun CharSequence.lastIndexOf(
string: String,
startIndex: Int = lastIndex,
ignoreCase: Boolean = false
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Finds the index of the last occurrence of any of the specified chars in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.lastIndexOfAny(
chars: CharArray,
startIndex: Int = lastIndex,
ignoreCase: Boolean = false
): Int
Finds the index of the last occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
fun CharSequence.lastIndexOfAny(
strings: Collection<String>,
startIndex: Int = lastIndex,
ignoreCase: Boolean = false
): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the last character, or null
if the char sequence is empty.
fun CharSequence.lastOrNull(): Char?
Returns the last character matching the given predicate, or null
if no such character was found.
fun CharSequence.lastOrNull(
predicate: (Char) -> Boolean
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Splits this char sequence to a list of lines delimited by any of the following character sequences: CRLF, LF or CR.
fun CharSequence.lines(): List<String>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Splits this char sequence to a sequence of lines delimited by any of the following character sequences: CRLF, LF or CR.
fun CharSequence.lineSequence(): Sequence<String>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a list containing the results of applying the given transform function to each character in the original char sequence.
fun <R> CharSequence.map(transform: (Char) -> R): List<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a list containing the results of applying the given transform function to each character and its index in the original char sequence.
fun <R> CharSequence.mapIndexed(
transform: (index: Int, Char) -> R
): List<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a list containing only the non-null results of applying the given transform function to each character and its index in the original char sequence.
fun <R : Any> CharSequence.mapIndexedNotNull(
transform: (index: Int, Char) -> R?
): List<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Applies the given transform function to each character and its index in the original char sequence and appends only the non-null results to the given destination.
fun <R : Any, C : MutableCollection<in R>> CharSequence.mapIndexedNotNullTo(
destination: C,
transform: (index: Int, Char) -> R?
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Applies the given transform function to each character and its index in the original char sequence and appends the results to the given destination.
fun <R, C : MutableCollection<in R>> CharSequence.mapIndexedTo(
destination: C,
transform: (index: Int, Char) -> R
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a list containing only the non-null results of applying the given transform function to each character in the original char sequence.
fun <R : Any> CharSequence.mapNotNull(
transform: (Char) -> R?
): List<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Applies the given transform function to each character in the original char sequence and appends only the non-null results to the given destination.
fun <R : Any, C : MutableCollection<in R>> CharSequence.mapNotNullTo(
destination: C,
transform: (Char) -> R?
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Applies the given transform function to each character of the original char sequence and appends the results to the given destination.
fun <R, C : MutableCollection<in R>> CharSequence.mapTo(
destination: C,
transform: (Char) -> R
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence matches the given regular expression.
infix fun CharSequence.matches(regex: Regex): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the largest character or null
if there are no characters.
fun CharSequence.max(): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character yielding the largest value of the given function or null
if there are no characters.
fun <R : Comparable<R>> CharSequence.maxBy(
selector: (Char) -> R
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character having the largest value according to the provided comparator or null
if there are no characters.
fun CharSequence.maxWith(
comparator: Comparator<in Char>
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the smallest character or null
if there are no characters.
fun CharSequence.min(): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character yielding the smallest value of the given function or null
if there are no characters.
fun <R : Comparable<R>> CharSequence.minBy(
selector: (Char) -> R
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the first character having the smallest value according to the provided comparator or null
if there are no characters.
fun CharSequence.minWith(
comparator: Comparator<in Char>
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if the char sequence has no characters.
fun CharSequence.none(): Boolean
Returns true
if no characters match the given predicate.
fun CharSequence.none(predicate: (Char) -> Boolean): Boolean
Platform and version requirements: JVM (1.1), JS (1.1), Native (1.1)
Performs the given action on each character and returns the char sequence itself afterwards.
fun <S : CharSequence> S.onEach(action: (Char) -> Unit): S
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence with content of this char sequence padded at the end to the specified length with the specified character or space.
fun CharSequence.padEnd(
length: Int,
padChar: Char = ' '
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence with content of this char sequence padded at the beginning to the specified length with the specified character or space.
fun CharSequence.padStart(
length: Int,
padChar: Char = ' '
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Splits the original char sequence into pair of char sequences, where first char sequence contains characters for which predicate yielded true
, while second char sequence contains characters for which predicate yielded false
.
fun CharSequence.partition(
predicate: (Char) -> Boolean
): Pair<CharSequence, CharSequence>
Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
Returns a random character from this char sequence.
fun CharSequence.random(): Char
Returns a random character from this char sequence using the specified source of randomness.
fun CharSequence.random(random: Random): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with the first character and applying operation from left to right to current accumulator value and each character.
fun CharSequence.reduce(
operation: (acc: Char, Char) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with the first character and applying operation from left to right to current accumulator value and each character with its index in the original char sequence.
fun CharSequence.reduceIndexed(
operation: (index: Int, acc: Char, Char) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with last character and applying operation from right to left to each character and current accumulator value.
fun CharSequence.reduceRight(
operation: (Char, acc: Char) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Accumulates value starting with last character and applying operation from right to left to each character with its index in the original char sequence and current accumulator value.
fun CharSequence.reduceRightIndexed(
operation: (index: Int, Char, acc: Char) -> Char
): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
If this char sequence starts with the given prefix, returns a new char sequence with the prefix removed. Otherwise, returns a new char sequence with the same characters.
fun CharSequence.removePrefix(
prefix: CharSequence
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence with content of this char sequence where its part at the given range is removed.
fun CharSequence.removeRange(
startIndex: Int,
endIndex: Int
): CharSequence
Returns a char sequence with content of this char sequence where its part at the given range is removed.
fun CharSequence.removeRange(range: IntRange): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
If this char sequence ends with the given suffix, returns a new char sequence with the suffix removed. Otherwise, returns a new char sequence with the same characters.
fun CharSequence.removeSuffix(
suffix: CharSequence
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
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.
fun CharSequence.removeSurrounding(
prefix: CharSequence,
suffix: 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.
fun CharSequence.removeSurrounding(
delimiter: CharSequence
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given replacement.
fun CharSequence.replace(
regex: Regex,
replacement: String
): String
Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the result of the given function transform that takes MatchResult and returns a string to be used as a replacement for that match.
fun CharSequence.replace(
regex: Regex,
transform: (MatchResult) -> CharSequence
): String
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Replaces the first occurrence of the given regular expression regex in this char sequence with specified replacement expression.
fun CharSequence.replaceFirst(
regex: Regex,
replacement: String
): String
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence with content of this char sequence where its part at the given range is replaced with the replacement char sequence.
fun CharSequence.replaceRange(
startIndex: Int,
endIndex: Int,
replacement: CharSequence
): CharSequence
Returns a char sequence with content of this char sequence where its part at the given range is replaced with the replacement char sequence.
fun CharSequence.replaceRange(
range: IntRange,
replacement: CharSequence
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence with characters in reversed order.
fun CharSequence.reversed(): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the single character, or throws an exception if the char sequence is empty or has more than one character.
fun CharSequence.single(): Char
Returns the single character matching the given predicate, or throws exception if there is no or more than one matching character.
fun CharSequence.single(predicate: (Char) -> Boolean): Char
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns single character, or null
if the char sequence is empty or has more than one character.
fun CharSequence.singleOrNull(): Char?
Returns the single character matching the given predicate, or null
if character was not found or more than one character was found.
fun CharSequence.singleOrNull(
predicate: (Char) -> Boolean
): Char?
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a char sequence containing characters of the original char sequence at the specified range of indices.
fun CharSequence.slice(indices: IntRange): CharSequence
Returns a char sequence containing characters of the original char sequence at specified indices.
fun CharSequence.slice(indices: Iterable<Int>): CharSequence
Splits this char sequence to a list of strings around occurrences of the specified delimiters.
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.split(
vararg delimiters: String,
ignoreCase: Boolean = false,
limit: Int = 0
): List<String>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.split(
vararg delimiters: Char,
ignoreCase: Boolean = false,
limit: Int = 0
): List<String>
Splits this char sequence around matches of the given regular expression.
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun CharSequence.split(
regex: Regex,
limit: Int = 0
): List<String>
Platform and version requirements: JVM (1.0)
fun CharSequence.split(
regex: Pattern,
limit: Int = 0
): List<String>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Splits this char sequence to a sequence of strings around occurrences of the specified delimiters.
fun CharSequence.splitToSequence(
vararg delimiters: String,
ignoreCase: Boolean = false,
limit: Int = 0
): Sequence<String>
fun CharSequence.splitToSequence(
vararg delimiters: Char,
ignoreCase: Boolean = false,
limit: Int = 0
): Sequence<String>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns true
if this char sequence starts with the specified character.
fun CharSequence.startsWith(
char: Char,
ignoreCase: Boolean = false
): Boolean
Returns true
if this char sequence starts with the specified prefix.
fun CharSequence.startsWith(
prefix: CharSequence,
ignoreCase: Boolean = false
): Boolean
Returns true
if a substring of this char sequence starting at the specified offset startIndex starts with the specified prefix.
fun CharSequence.startsWith(
prefix: CharSequence,
startIndex: Int,
ignoreCase: Boolean = false
): Boolean
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence specified by the given range of indices.
fun CharSequence.subSequence(range: IntRange): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a substring of chars from a range of this char sequence starting at the startIndex and ending right before the endIndex.
fun CharSequence.substring(
startIndex: Int,
endIndex: Int = length
): String
Returns a substring of chars at indices from the specified range of this char sequence.
fun CharSequence.substring(range: IntRange): String
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the sum of all values produced by selector function applied to each character in the char sequence.
fun CharSequence.sumBy(selector: (Char) -> Int): Int
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns the sum of all values produced by selector function applied to each character in the char sequence.
fun CharSequence.sumByDouble(
selector: (Char) -> Double
): Double
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing the first n characters from this char sequence, or the entire char sequence if this char sequence is shorter.
fun CharSequence.take(n: Int): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing the last n characters from this char sequence, or the entire char sequence if this char sequence is shorter.
fun CharSequence.takeLast(n: Int): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing last characters that satisfy the given predicate.
fun CharSequence.takeLastWhile(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a subsequence of this char sequence containing the first characters that satisfy the given predicate.
fun CharSequence.takeWhile(
predicate: (Char) -> Boolean
): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Appends all characters to the given destination collection.
fun <C : MutableCollection<in Char>> CharSequence.toCollection(
destination: C
): C
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a HashSet of all characters.
fun CharSequence.toHashSet(): HashSet<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a List containing all characters.
fun CharSequence.toList(): List<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a MutableList filled with all characters of this char sequence.
fun CharSequence.toMutableList(): MutableList<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a Set of all characters.
fun CharSequence.toSet(): Set<Char>
Platform and version requirements: JVM (1.0)
Returns a SortedSet of all characters.
fun CharSequence.toSortedSet(): SortedSet<Char>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a sub sequence of this char sequence having leading and trailing characters matching the predicate removed.
fun CharSequence.trim(
predicate: (Char) -> Boolean
): CharSequence
Returns a sub sequence of this char sequence having leading and trailing characters from the chars array removed.
fun CharSequence.trim(vararg chars: Char): CharSequence
Returns a sub sequence of this char sequence having leading and trailing whitespace removed.
fun CharSequence.trim(): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a sub sequence of this char sequence having trailing characters matching the predicate removed.
fun CharSequence.trimEnd(
predicate: (Char) -> Boolean
): CharSequence
Returns a sub sequence of this char sequence having trailing characters from the chars array removed.
fun CharSequence.trimEnd(vararg chars: Char): CharSequence
Returns a sub sequence of this char sequence having trailing whitespace removed.
fun CharSequence.trimEnd(): CharSequence
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a sub sequence of this char sequence having leading characters matching the predicate removed.
fun CharSequence.trimStart(
predicate: (Char) -> Boolean
): CharSequence
Returns a sub sequence of this char sequence having leading characters from the chars array removed.
fun CharSequence.trimStart(vararg chars: Char): CharSequence
Returns a sub sequence of this char sequence having leading whitespace removed.
fun CharSequence.trimStart(): CharSequence
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns a list of snapshots of the window of the given size sliding along this char sequence with the given step, where each snapshot is a string.
fun CharSequence.windowed(
size: Int,
step: Int = 1,
partialWindows: Boolean = false
): List<String>
Returns a list of results of applying the given transform function to an each char sequence representing a view over the window of the given size sliding along this char sequence with the given step.
fun <R> CharSequence.windowed(
size: Int,
step: Int = 1,
partialWindows: Boolean = false,
transform: (CharSequence) -> R
): List<R>
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns a sequence of snapshots of the window of the given size sliding along this char sequence with the given step, where each snapshot is a string.
fun CharSequence.windowedSequence(
size: Int,
step: Int = 1,
partialWindows: Boolean = false
): Sequence<String>
Returns a sequence of results of applying the given transform function to an each char sequence representing a view over the window of the given size sliding along this char sequence with the given step.
fun <R> CharSequence.windowedSequence(
size: Int,
step: Int = 1,
partialWindows: Boolean = false,
transform: (CharSequence) -> R
): Sequence<R>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a lazy Iterable of IndexedValue for each character of the original char sequence.
fun CharSequence.withIndex(): Iterable<IndexedValue<Char>>
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
Returns a list of pairs built from the characters of this
and the other char sequences with the same index The returned list has length of the shortest char sequence.
infix fun CharSequence.zip(
other: CharSequence
): List<Pair<Char, Char>>
Returns a list of values built from the characters of this
and the other char sequences with the same index using the provided transform function applied to each pair of characters. The returned list has length of the shortest char sequence.
fun <V> CharSequence.zip(
other: CharSequence,
transform: (a: Char, b: Char) -> V
): List<V>
Platform and version requirements: JVM (1.2), JS (1.2), Native (1.2)
Returns a list of pairs of each two adjacent characters in this char sequence.
fun CharSequence.zipWithNext(): List<Pair<Char, Char>>
Returns a list containing the results of applying the given transform function to an each pair of two adjacent characters in this char sequence.
fun <R> CharSequence.zipWithNext(
transform: (a: Char, b: Char) -> R
): List<R>