StringBuilder
A mutable sequence of characters.
String builder can be used to efficiently perform multiple string manipulation operations.
Since Kotlin
1.0A mutable sequence of characters.
String builder can be used to efficiently perform multiple string manipulation operations.
Since Kotlin
1.1Since Kotlin
1.1A mutable sequence of characters.
String builder can be used to efficiently perform multiple string manipulation operations.
Since Kotlin
1.3Constructors
Constructs an empty string builder.
Constructs an empty string builder with the specified initial capacity.
Constructs a string builder that contains the same characters as the specified content char sequence.
Constructs a string builder that contains the same characters as the specified content string.
Constructs an empty string builder.
Constructs an empty string builder with the specified initial capacity.
Constructs a string builder that contains the same characters as the specified content char sequence.
Constructs an empty string builder.
Constructs an empty string builder with the specified initial capacity.
Constructs a string builder that contains the same characters as the specified content char sequence.
Constructs a string builder that contains the same characters as the specified content string.
Properties
Functions
Returns true
if char sequence has at least one character.
Returns true
if at least one character matches the given predicate.
Appends the string representation of the specified object value to this string builder and returns this instance.
Appends the string representation of the specified boolean value to this string builder and returns this instance.
Appends the specified character value to this Appendable and returns this instance.
Appends characters in the specified character array value to this string builder and returns this instance.
Appends the specified character sequence value to this Appendable and returns this instance.
Appends the specified string value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this Appendable and returns this instance.
Appends the string representation of the specified object value to this string builder and returns this instance.
Appends the string representation of the specified boolean value to this string builder and returns this instance.
Appends the specified character value to this Appendable and returns this instance.
Appends characters in the specified character array value to this string builder and returns this instance.
Appends the specified character sequence value to this Appendable and returns this instance.
Appends the specified string value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this Appendable and returns this instance.
Appends the string representation of the specified object value to this string builder and returns this instance.
Appends the string representation of the specified boolean value to this string builder and returns this instance.
Appends the specified character value to this Appendable and returns this instance.
Appends characters in the specified character array value to this string builder and returns this instance.
Appends the specified character sequence value to this Appendable and returns this instance.
Appends the specified string value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this Appendable and returns this instance.
Appends all arguments to the given StringBuilder.
Appends a line feed character (\n
) to this Appendable.
Appends a line feed character (\n
) to this StringBuilder.
Appends value to the given Appendable and a line feed character (\n
) after it.
Appends value to this StringBuilder, followed by a line feed character (\n
).
Appends value to this StringBuilder, followed by a line feed character (\n
).
Appends value to this StringBuilder, followed by a line feed character (\n
).
Appends a line separator to this Appendable.
Appends a line separator to this StringBuilder.
Appends value to the given Appendable and line separator after it.
Appends value to this StringBuilder, followed by a line separator.
Appends characters in a subarray of the specified character array value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this string builder and returns this instance.
Appends characters in a subarray of the specified character array value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this string builder and returns this instance.
Appends characters in a subarray of the specified character array value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this string builder and returns this instance.
Appends characters in a subarray of the specified character array value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this string builder and returns this instance.
Appends characters in a subarray of the specified character array value to this string builder and returns this instance.
Appends a subsequence of the specified character sequence value to this string builder and returns this instance.
Creates an Iterable instance that wraps the original char sequence returning its characters when being iterated.
Creates a Sequence instance that wraps the original char sequence returning its characters when being iterated.
Returns a Map containing the characters from the given char sequence indexed by the key returned from keySelector function applied to each character.
Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to characters of the given char sequence.
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.
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.
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each character of the given char sequence.
Returns a Map where keys are characters from the given char sequence and values are produced by the valueSelector function applied to each character.
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.
Clears the content of this string builder making it empty and returns this instance.
Clears the content of this string builder making it empty and returns this instance.
Clears the content of this string builder making it empty and returns this instance.
Clears the content of this string builder making it empty and returns this instance.
Clears the content of this string builder making it empty and returns this instance.
Returns true
if this char sequence contains at least one match of the specified regular expression regex.
Returns true
if this char sequence contains the specified character char.
Returns true
if this char sequence contains the specified other sequence of characters as a substring.
Returns the length of this char sequence.
Returns the number of characters matching the given predicate.
Removes the character at the specified index from this string builder and returns this instance.
Removes the character at the specified index from this string builder and returns this instance.
Removes the character at the specified index from this string builder and returns this instance.
Removes the character at the specified index from this string builder and returns this instance.
Removes the character at the specified index from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Removes characters in the specified range from this string builder and returns this instance.
Returns a subsequence of this char sequence with the first n characters removed.
Returns a subsequence of this char sequence with the last n characters removed.
Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given predicate.
Returns a subsequence of this char sequence containing all characters except first characters that satisfy the given predicate.
Returns a character at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this char sequence.
Returns a character at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this char sequence.
Returns a character at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this char sequence.
Returns a character at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this char sequence.
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.
Returns true
if this char sequence ends with the specified character.
Returns true
if this char sequence ends with the specified suffix.
Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.
Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.
Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.
Returns a char sequence containing only those characters from the original char sequence that match the given predicate.
Returns a char sequence containing only those characters from the original char sequence that match the given predicate.
Appends all characters matching the given predicate to the given destination.
Returns a char sequence containing only those characters from the original char sequence that do not match the given predicate.
Appends all characters not matching the given predicate to the given destination.
Appends all characters matching the given predicate to the given destination.
Finds the first occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
Finds the last occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
Returns first character.
Returns the first character matching the given predicate.
Returns the first character, or null
if the char sequence is empty.
Returns the first character matching the given predicate, or null
if character was not found.
Returns a single list of all elements yielded from results of transform function being invoked on each character and its index in the original char sequence.
Appends all elements yielded from results of transform function being invoked on each character and its index in the original char sequence, to the given destination.
Appends all elements yielded from results of transform function being invoked on each character of original char sequence, to the given destination.
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.
Performs the given action on each character, providing sequential index with the character.
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.
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.
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.
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.
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.
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.
Returns true
if this CharSequence has Unicode surrogate pair at the specified index.
Returns the index within this string builder of the first occurrence of the specified string.
Returns the index within this string builder of the first occurrence of the specified string, starting at the specified startIndex.
Returns the index within this string builder of the first occurrence of the specified string.
Returns the index within this string builder of the first occurrence of the specified string, starting at the specified startIndex.
Returns the index within this string builder of the first occurrence of the specified string.
Returns the index within this string builder of the first occurrence of the specified string, starting at the specified startIndex.
Returns the index within this string of the first occurrence of the specified character, starting from the specified startIndex.
Returns the index within this char sequence of the first occurrence of the specified string, starting from the specified startIndex.
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.
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.
Returns index of the first character matching the given predicate, or -1 if the char sequence does not contain such character.
Returns index of the last character matching the given predicate, or -1 if the char sequence does not contain such character.
Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.
Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.
Inserts the specified character value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.
Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.
Inserts the specified character value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.
Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.
Inserts the specified character value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence csq into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.
Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.
Returns true
if this string is empty or consists solely of whitespace characters.
Returns true
if this string is empty or consists solely of whitespace characters.
Returns true
if this string is empty or consists solely of whitespace characters.
Returns true
if this char sequence is empty (contains no characters).
Returns true
if this char sequence is not empty and contains some characters except of whitespace characters.
Returns true
if this char sequence is not empty.
Returns true
if this nullable char sequence is either null
or empty or consists solely of whitespace characters.
Returns true
if this nullable char sequence is either null
or empty.
Iterator for characters of the given char sequence.
Returns the last character.
Returns the last character matching the given predicate.
Returns the index within this string builder of the last occurrence of the specified string. The last occurrence of empty string ""
is considered to be at the index equal to this.length
.
Returns the index within this string builder of the last occurrence of the specified string, starting from the specified startIndex toward the beginning.
Returns the index within this string builder of the last occurrence of the specified string. The last occurrence of empty string ""
is considered to be at the index equal to this.length
.
Returns the index within this string builder of the last occurrence of the specified string, starting from the specified startIndex toward the beginning.
Returns the index within this string builder of the last occurrence of the specified string. The last occurrence of empty string ""
is considered to be at the index equal to this.length
.
Returns the index within this string builder of the last occurrence of the specified string, starting from the specified startIndex toward the beginning.
Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified startIndex.
Returns the index within this char sequence of the last occurrence of the specified string, starting from the specified startIndex.
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.
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.
Returns the last character, or null
if the char sequence is empty.
Returns the last character matching the given predicate, or null
if no such character was found.
Splits this char sequence to a list of lines delimited by any of the following character sequences: CRLF, LF or CR.
Splits this char sequence to a sequence of lines delimited by any of the following character sequences: CRLF, LF or CR.
Returns a list containing the results of applying the given transform function to each character and its index in the original char sequence.
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.
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.
Applies the given transform function to each character and its index in the original char sequence and appends the results to the given destination.
Returns a list containing only the non-null results of applying the given transform function to each character in the original char sequence.
Applies the given transform function to each character in the original char sequence and appends only the non-null results to the given destination.
Applies the given transform function to each character of the original char sequence and appends the results to the given destination.
Returns true
if this char sequence matches the given regular expression.
Returns the first character yielding the largest value of the given function or null
if there are no characters.
Returns the largest value among all values produced by selector function applied to each character in the char sequence.
Returns the largest value among all values produced by selector function applied to each character in the char sequence or null
if there are no characters.
Returns the largest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence.
Returns the largest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence or null
if there are no characters.
Returns the largest character or null
if there are no characters.
Returns the first character having the largest value according to the provided comparator or null
if there are no characters.
Returns the first character yielding the smallest value of the given function or null
if there are no characters.
Returns the smallest value among all values produced by selector function applied to each character in the char sequence.
Returns the smallest value among all values produced by selector function applied to each character in the char sequence or null
if there are no characters.
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence.
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence or null
if there are no characters.
Returns the smallest character or null
if there are no characters.
Returns the first character having the smallest value according to the provided comparator or null
if there are no characters.
Returns true
if the char sequence has no characters.
Returns true
if no characters match the given predicate.
Returns a char sequence with content of this char sequence padded at the end to the specified length with the specified character or space.
Returns a char sequence with content of this char sequence padded at the beginning to the specified length with the specified character or space.
Returns a random character from this char sequence.
Returns a random character from this char sequence using the specified source of randomness.
Returns a random character from this char sequence, or null
if this char sequence is empty.
Returns a random character from this char sequence using the specified source of randomness, or null
if this char sequence is empty.
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.
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.
Accumulates value starting with the first character and applying operation from left to right to current accumulator value and each character.
Accumulates value starting with the last character and applying operation from right to left to each character and current accumulator value.
Accumulates value starting with the last character and applying operation from right to left to each character with its index in the original char sequence and current accumulator value.
Accumulates value starting with the last character and applying operation from right to left to each character with its index in the original char sequence and current accumulator value.
Accumulates value starting with the last character and applying operation from right to left to each character and current accumulator value.
Returns true
if the specified range in this char sequence is equal to the specified range in another char sequence.
Returns true
if the specified range in this char sequence is equal to the specified range in another char sequence.
Returns true
if the specified range in this char sequence is equal to the specified range in another char sequence.
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.
Returns a char sequence with content of this char sequence where its part at the given range is removed.
Returns a char sequence with content of this char sequence where its part at the given range is removed.
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.
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.
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.
Returns a string containing this char sequence repeated n times.
Returns a string containing this char sequence repeated n times.
Returns a string containing this char sequence repeated n times.
Returns a string containing this char sequence repeated n times.
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.
Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given replacement.
Replaces the first occurrence of the given regular expression regex in this char sequence with specified replacement expression.
Returns a char sequence with content of this char sequence where its part at the given range is replaced with the replacement char sequence.
Returns a char sequence with content of this char sequence where its part at the given range is replaced with the replacement char sequence.
Reverses the contents of this string builder and returns this instance.
Reverses the contents of this string builder and returns this instance.
Reverses the contents of this string builder and returns this instance.
Returns a char sequence with characters in reversed order.
Returns a list containing successive accumulation values generated by applying operation from left to right to each character, its index in the original char sequence and current accumulator value that starts with initial value.
Returns a list containing successive accumulation values generated by applying operation from left to right to each character and current accumulator value that starts with the first character of this char sequence.
Returns a list containing successive accumulation values generated by applying operation from left to right to each character, its index in the original char sequence and current accumulator value that starts with the first character of this char sequence.
Returns a list containing successive accumulation values generated by applying operation from left to right to each character, its index in the original char sequence and current accumulator value that starts with initial value.
Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.
Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.
Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.
Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.
Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.
Returns the single character, or throws an exception if the char sequence is empty or has more than one character.
Returns the single character matching the given predicate, or throws exception if there is no or more than one matching character.
Returns single character, or null
if the char sequence is empty or has more than one character.
Returns the single character matching the given predicate, or null
if character was not found or more than one character was found.
Splits this char sequence to a list of strings around matches of the given regular expression.
Splits this char sequence to a list of strings around occurrences of the specified delimiters.
Splits this char sequence to a sequence of strings around occurrences of the specified delimiters.
Returns true
if this char sequence starts with the specified character.
Returns true
if this char sequence starts with the specified prefix.
Returns true
if a substring of this char sequence starting at the specified offset startIndex starts with the specified prefix.
Returns a new character sequence that is a subsequence of this character sequence, starting at the specified startIndex and ending right before the specified endIndex.
Returns a new character sequence that is a subsequence of this character sequence, starting at the specified startIndex and ending right before the specified endIndex.
Returns a new character sequence that is a subsequence of this character sequence, starting at the specified startIndex and ending right before the specified endIndex.
Returns a subsequence of this char sequence specified by the given range of indices.
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).
Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).
Returns a substring of chars at indices from the specified range of this char sequence.
Returns a substring of chars from a range of this char sequence starting at the startIndex and ending right before the endIndex.
Returns the sum of all values produced by selector function applied to each character in the char sequence.
Returns the sum of all values produced by selector function applied to each character in the char sequence.
Returns the sum of all values produced by selector function applied to each character in the char sequence.
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.
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.
Returns a subsequence of this char sequence containing last characters that satisfy the given predicate.
Returns a subsequence of this char sequence containing the first characters that satisfy the given predicate.
Copies characters from this string builder into the destination character array.
Copies characters from this string builder into the destination character array.
Copies characters from this string builder into the destination character array.
Copies characters from this string builder into the destination character array.
Copies characters from this string builder into the destination character array.
Copies characters from this string builder into the destination character array.
Appends all characters to the given destination collection.
Returns a new MutableList filled with all characters of this char sequence.
Returns a new SortedSet of all characters.
Returns a sub sequence of this char sequence having leading and trailing whitespace removed.
Returns a sub sequence of this char sequence having leading and trailing characters from the chars array removed.
Returns a sub sequence of this char sequence having leading and trailing characters matching the predicate removed.
Returns a sub sequence of this char sequence having trailing whitespace removed.
Returns a sub sequence of this char sequence having trailing characters from the chars array removed.
Returns a sub sequence of this char sequence having trailing characters matching the predicate removed.
Returns a sub sequence of this char sequence having leading whitespace removed.
Returns a sub sequence of this char sequence having leading characters from the chars array removed.
Returns a sub sequence of this char sequence having leading characters matching the predicate removed.
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.
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.
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.
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.
Returns a lazy Iterable that wraps each character of the original char sequence into an IndexedValue containing the index of that character and the character itself.
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.
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.
Returns a list of pairs of each two adjacent characters in this char sequence.
Returns a list containing the results of applying the given transform function to an each pair of two adjacent characters in this char sequence.