String
The
String
class represents character strings. All string literals in Kotlin programs, such as
"abc"
, are
implemented as instances of this class.
Constructors
<init>
The
String
class represents character strings. All string literals in Kotlin programs, such as
"abc"
, are
implemented as instances of this class.
<init>
(
)
Properties
length
Returns the length of this character sequence.
val
length
:
Int
Functions
equals
Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:
fun
equals
(
other
:
Any
?
)
:
Boolean
hashCode
Returns a hash code value for the object. The general contract of
hashCode
is:
fun
hashCode
(
)
:
Int
plus
Returns a string obtained by concatenating this string with the string representation of the given other object.
operator
fun
plus
(
other
:
Any
?
)
:
String
subSequence
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 .
fun
subSequence
(
startIndex
:
Int
,
endIndex
:
Int
)
:
CharSequence
toString
Returns a string representation of the object.
fun
toString
(
)
:
String
Extension Properties
indices
Returns the range of valid character indices for this char sequence.
val
CharSequence
.
indices
:
IntRange
lastIndex
Returns the index of the last character in the char sequence or -1 if it is empty.
val
CharSequence
.
lastIndex
:
Int
Extension Functions
all
Returns
true
if all characters match the given
predicate
.
fun
CharSequence
.
all
(
predicate
:
(
Char
)
->
Boolean
)
:
Boolean
any
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
asIterable
Creates an Iterable instance that wraps the original char sequence returning its characters when being iterated.
fun
CharSequence
.
asIterable
(
)
:
Iterable
<
Char
>
asSequence
Creates a Sequence instance that wraps the original char sequence returning its characters when being iterated.
fun
CharSequence
.
asSequence
(
)
:
Sequence
<
Char
>
associate
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
>
associateBy
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
>
associateByTo
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
associateTo
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
associateWith
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
>
associateWithTo
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
byteInputStream
Creates a new byte input stream for the string.
fun
String
.
byteInputStream
(
charset
:
Charset
=
Charsets.UTF_8
)
:
ByteArrayInputStream
chunked
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
>
chunkedSequence
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
>
codePointAt
Returns the character (Unicode code point) at the specified index.
fun
String
.
codePointAt
(
index
:
Int
)
:
Int
codePointBefore
Returns the character (Unicode code point) before the specified index.
fun
String
.
codePointBefore
(
index
:
Int
)
:
Int
codePointCount
Returns the number of Unicode code points in the specified text range of this String.
fun
String
.
codePointCount
(
beginIndex
:
Int
,
endIndex
:
Int
)
:
Int
coerceAtLeast
Ensures that this value is not less than the specified minimumValue .
fun
<
T
:
Comparable
<
T
>
>
T
.
coerceAtLeast
(
minimumValue
:
T
)
:
T
coerceAtMost
Ensures that this value is not greater than the specified maximumValue .
fun
<
T
:
Comparable
<
T
>
>
T
.
coerceAtMost
(
maximumValue
:
T
)
:
T
coerceIn
Ensures that this value lies in the specified range minimumValue .. maximumValue .
fun
<
T
:
Comparable
<
T
>
>
T
.
coerceIn
(
minimumValue
:
T
?
,
maximumValue
:
T
?
)
:
T
Ensures that this value lies in the specified range .
fun
<
T
:
Comparable
<
T
>
>
T
.
coerceIn
(
range
:
ClosedFloatingPointRange
<
T
>
)
:
T
fun
<
T
:
Comparable
<
T
>
>
T
.
coerceIn
(
range
:
ClosedRange
<
T
>
)
:
T
commonPrefixWith
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
commonSuffixWith
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
compareTo
Compares this object with the specified object for order. Returns zero if this object is equal to the specified other object, a negative number if it's less than other , or a positive number if it's greater than other .
infix
fun
<
T
>
Comparable
<
T
>
.
compareTo
(
other
:
T
)
:
Int
concat
fun
String
.
concat
(
str
:
String
)
:
String
contains
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
contentEquals
Returns
true
if this string is equal to the contents of the specified
CharSequence
,
false
otherwise.
fun
String
.
contentEquals
(
charSequence
:
CharSequence
)
:
Boolean
Returns
true
if this string is equal to the contents of the specified
StringBuffer
,
false
otherwise.
fun
String
.
contentEquals
(
stringBuilder
:
StringBuffer
)
:
Boolean
count
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
dropLast
Returns a string with the last n characters removed.
fun
String
.
dropLast
(
n
:
Int
)
:
String
dropLastWhile
Returns a string containing all characters except last characters that satisfy the given predicate .
fun
String
.
dropLastWhile
(
predicate
:
(
Char
)
->
Boolean
)
:
String
dropWhile
Returns a string containing all characters except first characters that satisfy the given predicate .
fun
String
.
dropWhile
(
predicate
:
(
Char
)
->
Boolean
)
:
String
elementAtOrElse
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
elementAtOrNull
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
?
endsWith
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
filter
Returns a string containing only those characters from the original string that match the given predicate .
fun
String
.
filter
(
predicate
:
(
Char
)
->
Boolean
)
:
String
filterIndexed
Returns a string containing only those characters from the original string that match the given predicate .
fun
String
.
filterIndexed
(
predicate
:
(
index
:
Int
,
Char
)
->
Boolean
)
:
String
filterIndexedTo
Appends all characters matching the given predicate to the given destination .
fun
<
C
:
Appendable
>
CharSequence
.
filterIndexedTo
(
destination
:
C
,
predicate
:
(
index
:
Int
,
Char
)
->
Boolean
)
:
C
filterNot
Returns a string containing only those characters from the original string that do not match the given predicate .
fun
String
.
filterNot
(
predicate
:
(
Char
)
->
Boolean
)
:
String
filterNotTo
Appends all characters not matching the given predicate to the given destination .
fun
<
C
:
Appendable
>
CharSequence
.
filterNotTo
(
destination
:
C
,
predicate
:
(
Char
)
->
Boolean
)
:
C
filterTo
Appends all characters matching the given predicate to the given destination .
fun
<
C
:
Appendable
>
CharSequence
.
filterTo
(
destination
:
C
,
predicate
:
(
Char
)
->
Boolean
)
:
C
find
Returns the first character matching the given
predicate
, or
null
if no such character was found.
fun
CharSequence
.
find
(
predicate
:
(
Char
)
->
Boolean
)
:
Char
?
findAnyOf
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
>
?
findLast
Returns the last character matching the given
predicate
, or
null
if no such character was found.
fun
CharSequence
.
findLast
(
predicate
:
(
Char
)
->
Boolean
)
:
Char
?
findLastAnyOf
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
>
?
first
Returns the first character.
fun
CharSequence
.
first
(
)
:
Char
Returns the first character matching the given predicate .
fun
CharSequence
.
first
(
predicate
:
(
Char
)
->
Boolean
)
:
Char
firstNotNullOf
Returns the first non-null value produced by transform function being applied to characters of this char sequence in iteration order, or throws NoSuchElementException if no non-null value was produced.
fun
<
R
:
Any
>
CharSequence
.
firstNotNullOf
(
transform
:
(
Char
)
->
R
?
)
:
R
firstNotNullOfOrNull
Returns the first non-null value produced by
transform
function being applied to characters of this char sequence in iteration order,
or
null
if no non-null value was produced.
fun
<
R
:
Any
>
CharSequence
.
firstNotNullOfOrNull
(
transform
:
(
Char
)
->
R
?
)
:
R
?
firstOrNull
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
?
flatMap
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
>
flatMapIndexed
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.
fun
<
R
>
CharSequence
.
flatMapIndexed
(
transform
:
(
index
:
Int
,
Char
)
->
Iterable
<
R
>
)
:
List
<
R
>
flatMapIndexedTo
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 .
fun
<
R
,
C
:
MutableCollection
<
in
R
>
>
CharSequence
.
flatMapIndexedTo
(
destination
:
C
,
transform
:
(
index
:
Int
,
Char
)
->
Iterable
<
R
>
)
:
C
flatMapTo
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
fold
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
foldIndexed
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
foldRight
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
foldRightIndexed
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
forEach
Performs the given action on each character.
fun
CharSequence
.
forEach
(
action
:
(
Char
)
->
Unit
)
forEachIndexed
Performs the given action on each character, providing sequential index with the character.
fun
CharSequence
.
forEachIndexed
(
action
:
(
index
:
Int
,
Char
)
->
Unit
)
format
Uses this string as a format string and returns a string obtained by substituting format specifiers in the format string with the provided arguments, using the default locale.
fun
String
.
format
(
vararg
args
:
Any
?
)
:
String
Uses this string as a format string and returns a string obtained
by substituting format specifiers in the format string with the provided arguments,
using the specified locale. If
locale
is
null
then no localization is applied.
fun
String
.
format
(
locale
:
Locale
?
,
vararg
args
:
Any
?
)
:
String
getOrElse
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
getOrNull
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
?
groupBy
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
>
>
groupByTo
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
groupingBy
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
>
hasSurrogatePairAt
Returns
true
if this CharSequence has Unicode surrogate pair at the specified
index
.
fun
CharSequence
.
hasSurrogatePairAt
(
index
:
Int
)
:
Boolean
hexToUByteArray
Parses bytes from this string using the specified HexFormat .
fun
String
.
hexToUByteArray
(
format
:
HexFormat
=
HexFormat.Default
)
:
UByteArray
ifBlank
Returns this char sequence if it is not empty and doesn't consist solely of whitespace characters, or the result of calling defaultValue function otherwise.
fun
<
C
,
R
>
C
.
ifBlank
(
defaultValue
:
(
)
->
R
)
:
R
where
C
:
CharSequence
,
C
:
R
ifEmpty
Returns this char sequence if it's not empty or the result of calling defaultValue function if the char sequence is empty.
fun
<
C
,
R
>
C
.
ifEmpty
(
defaultValue
:
(
)
->
R
)
:
R
where
C
:
CharSequence
,
C
:
R
indexOf
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
indexOfAny
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
indexOfFirst
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
indexOfLast
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
intern
Returns a canonical representation for this string object.
fun
String
.
intern
(
)
:
String
isEmpty
Returns
true
if this char sequence is empty (contains no characters).
fun
CharSequence
.
isEmpty
(
)
:
Boolean
isNotBlank
Returns
true
if this char sequence is not empty and contains some characters except of whitespace characters.
fun
CharSequence
.
isNotBlank
(
)
:
Boolean
isNotEmpty
Returns
true
if this char sequence is not empty.
fun
CharSequence
.
isNotEmpty
(
)
:
Boolean
isNullOrBlank
Returns
true
if this nullable char sequence is either
null
or empty or consists solely of whitespace characters.
fun
CharSequence
?
.
isNullOrBlank
(
)
:
Boolean
isNullOrEmpty
Returns
true
if this nullable char sequence is either
null
or empty.
fun
CharSequence
?
.
isNullOrEmpty
(
)
:
Boolean
iterator
Iterator for characters of the given char sequence.
operator
fun
CharSequence
.
iterator
(
)
:
CharIterator
last
Returns the last character.
fun
CharSequence
.
last
(
)
:
Char
Returns the last character matching the given predicate .
fun
CharSequence
.
last
(
predicate
:
(
Char
)
->
Boolean
)
:
Char
lastIndexOf
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
lastIndexOfAny
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
lastOrNull
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
?
lines
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
>
lineSequence
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
>
map
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
>
mapIndexed
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
>
mapIndexedNotNull
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
>
mapIndexedNotNullTo
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
mapIndexedTo
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
mapNotNull
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
>
mapNotNullTo
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
mapTo
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
match
fun
String
.
match
(
regex
:
String
)
:
Array
<
String
>
?
matches
Returns
true
if this char sequence matches the given regular expression.
infix
fun
CharSequence
.
matches
(
regex
:
Regex
)
:
Boolean
fun
String
.
matches
(
regex
:
String
)
:
Boolean
maxByOrNull
Returns the first character yielding the largest value of the given function or
null
if there are no characters.
fun
<
R
:
Comparable
<
R
>
>
CharSequence
.
maxByOrNull
(
selector
:
(
Char
)
->
R
)
:
Char
?
maxOf
Returns the largest value among all values produced by selector function applied to each character in the char sequence.
fun
<
R
:
Comparable
<
R
>
>
any_iterable
<R>
.
maxOf
(
selector
:
(
Char
)
->
R
)
:
R
maxOfOrNull
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.
fun
<
R
:
Comparable
<
R
>
>
any_iterable
<R>
.
maxOfOrNull
(
selector
:
(
Char
)
->
R
)
:
R
?
maxOfWith
Returns the largest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence.
fun
<
R
>
CharSequence
.
maxOfWith
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Char
)
->
R
)
:
R
maxOfWithOrNull
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.
fun
<
R
>
CharSequence
.
maxOfWithOrNull
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Char
)
->
R
)
:
R
?
maxOrNull
Returns the largest character or
null
if there are no characters.
fun
CharSequence
.
maxOrNull
(
)
:
Char
?
maxWith
Returns the first character having the largest value according to the provided comparator .
fun
CharSequence
.
maxWith
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
fun
CharSequence
.
maxWith
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
?
maxWithOrNull
Returns the first character having the largest value according to the provided
comparator
or
null
if there are no characters.
fun
CharSequence
.
maxWithOrNull
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
?
minByOrNull
Returns the first character yielding the smallest value of the given function or
null
if there are no characters.
fun
<
R
:
Comparable
<
R
>
>
CharSequence
.
minByOrNull
(
selector
:
(
Char
)
->
R
)
:
Char
?
minOf
Returns the smallest value among all values produced by selector function applied to each character in the char sequence.
fun
<
R
:
Comparable
<
R
>
>
any_iterable
<R>
.
minOf
(
selector
:
(
Char
)
->
R
)
:
R
minOfOrNull
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.
fun
<
R
:
Comparable
<
R
>
>
any_iterable
<R>
.
minOfOrNull
(
selector
:
(
Char
)
->
R
)
:
R
?
minOfWith
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each character in the char sequence.
fun
<
R
>
CharSequence
.
minOfWith
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Char
)
->
R
)
:
R
minOfWithOrNull
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.
fun
<
R
>
CharSequence
.
minOfWithOrNull
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Char
)
->
R
)
:
R
?
minOrNull
Returns the smallest character or
null
if there are no characters.
fun
CharSequence
.
minOrNull
(
)
:
Char
?
minWith
Returns the first character having the smallest value according to the provided comparator .
fun
CharSequence
.
minWith
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
fun
CharSequence
.
minWith
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
?
minWithOrNull
Returns the first character having the smallest value according to the provided
comparator
or
null
if there are no characters.
fun
CharSequence
.
minWithOrNull
(
comparator
:
Comparator
<
in
Char
>
)
:
Char
?
none
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
offsetByCodePoints
Returns the index within this string that is offset from the given index by codePointOffset code points.
fun
String
.
offsetByCodePoints
(
index
:
Int
,
codePointOffset
:
Int
)
:
Int
onEach
Performs the given action on each character and returns the char sequence itself afterwards.
fun
<
S
:
CharSequence
>
S
.
onEach
(
action
:
(
Char
)
->
Unit
)
:
S
onEachIndexed
Performs the given action on each character, providing sequential index with the character, and returns the char sequence itself afterwards.
fun
<
S
:
CharSequence
>
S
.
onEachIndexed
(
action
:
(
index
:
Int
,
Char
)
->
Unit
)
:
S
orEmpty
Returns the string if it is not
null
, or the empty string otherwise.
fun
String
?
.
orEmpty
(
)
:
String
padEnd
Pads the string to the specified length at the end with the specified character or space.
fun
String
.
padEnd
(
length
:
Int
,
padChar
:
Char
=
' '
)
:
String
padStart
Pads the string to the specified length at the beginning with the specified character or space.
fun
String
.
padStart
(
length
:
Int
,
padChar
:
Char
=
' '
)
:
String
prependIndent
Prepends indent to every line of the original string.
fun
String
.
prependIndent
(
indent
:
String
=
" "
)
:
String
random
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
randomOrNull
Returns a random character from this char sequence, or
null
if this char sequence is empty.
fun
CharSequence
.
randomOrNull
(
)
:
Char
?
Returns a random character from this char sequence using the specified source of randomness, or
null
if this char sequence is empty.
fun
CharSequence
.
randomOrNull
(
random
:
Random
)
:
Char
?
rangeTo
Creates a range from this Comparable value to the specified that value.
operator
fun
<
T
:
Comparable
<
T
>
>
T
.
rangeTo
(
that
:
T
)
:
ClosedRange
<
T
>
rangeUntil
Creates an open-ended range from this Comparable value to the specified that value.
operator
fun
<
T
:
Comparable
<
T
>
>
T
.
rangeUntil
(
that
:
T
)
:
OpenEndRange
<
T
>
reader
Creates a new reader for the string.
fun
String
.
reader
(
)
:
StringReader
reduce
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
reduceIndexed
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
reduceIndexedOrNull
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
.
reduceIndexedOrNull
(
operation
:
(
index
:
Int
,
acc
:
Char
,
Char
)
->
Char
)
:
Char
?
reduceOrNull
Accumulates value starting with the first character and applying operation from left to right to current accumulator value and each character.
fun
CharSequence
.
reduceOrNull
(
operation
:
(
acc
:
Char
,
Char
)
->
Char
)
:
Char
?
reduceRight
Accumulates value starting with the 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
reduceRightIndexed
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.
fun
CharSequence
.
reduceRightIndexed
(
operation
:
(
index
:
Int
,
Char
,
acc
:
Char
)
->
Char
)
:
Char
reduceRightIndexedOrNull
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.
fun
CharSequence
.
reduceRightIndexedOrNull
(
operation
:
(
index
:
Int
,
Char
,
acc
:
Char
)
->
Char
)
:
Char
?
reduceRightOrNull
Accumulates value starting with the last character and applying operation from right to left to each character and current accumulator value.
fun
CharSequence
.
reduceRightOrNull
(
operation
:
(
Char
,
acc
:
Char
)
->
Char
)
:
Char
?
refTo
fun
String
.
refTo
(
index
:
Int
)
:
CValuesRef
<
COpaque
>
removePrefix
If this string starts with the given prefix , returns a copy of this string with the prefix removed. Otherwise, returns this string.
fun
String
.
removePrefix
(
prefix
:
CharSequence
)
:
String
removeRange
Removes the part of a string at a given range.
fun
String
.
removeRange
(
startIndex
:
Int
,
endIndex
:
Int
)
:
String
removeSuffix
If this string ends with the given suffix , returns a copy of this string with the suffix removed. Otherwise, returns this string.
fun
String
.
removeSuffix
(
suffix
:
CharSequence
)
:
String
removeSurrounding
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.
fun
String
.
removeSurrounding
(
prefix
:
CharSequence
,
suffix
:
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.
fun
String
.
removeSurrounding
(
delimiter
:
CharSequence
)
:
String
replace
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
replaceAfter
Replace part of string after the first occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
replaceAfter
(
delimiter
:
Char
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
replaceAfter
(
delimiter
:
String
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
replaceAfterLast
Replace part of string after the last occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
replaceAfterLast
(
delimiter
:
String
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
replaceAfterLast
(
delimiter
:
Char
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
replaceBefore
Replace part of string before the first occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
replaceBefore
(
delimiter
:
Char
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
replaceBefore
(
delimiter
:
String
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
replaceBeforeLast
Replace part of string before the last occurrence of given delimiter with the replacement string. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
replaceBeforeLast
(
delimiter
:
Char
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
replaceBeforeLast
(
delimiter
:
String
,
replacement
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
replaceFirst
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
replaceFirstChar
Returns a copy of this string having its first character replaced with the result of the specified transform , or the original string if it's empty.
fun
String
.
replaceFirstChar
(
transform
:
(
Char
)
->
Char
)
:
String
fun
String
.
replaceFirstChar
(
transform
:
(
Char
)
->
CharSequence
)
:
String
replaceIndent
Detects a common minimal indent like it does trimIndent and replaces it with the specified newIndent .
fun
String
.
replaceIndent
(
newIndent
:
String
=
""
)
:
String
replaceIndentByMargin
Detects indent by marginPrefix as it does trimMargin and replace it with newIndent .
fun
String
.
replaceIndentByMargin
(
newIndent
:
String
=
""
,
marginPrefix
:
String
=
"|"
)
:
String
replaceRange
Replaces the part of the string at the given range with the replacement char sequence.
fun
String
.
replaceRange
(
startIndex
:
Int
,
endIndex
:
Int
,
replacement
:
CharSequence
)
:
String
Replace the part of string at the given range with the replacement string.
fun
String
.
replaceRange
(
range
:
IntRange
,
replacement
:
CharSequence
)
:
String
reversed
Returns a string with characters in reversed order.
fun
String
.
reversed
(
)
:
String
runningFold
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 initial value.
fun
<
R
>
CharSequence
.
runningFold
(
initial
:
R
,
operation
:
(
acc
:
R
,
Char
)
->
R
)
:
List
<
R
>
runningFoldIndexed
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.
fun
<
R
>
CharSequence
.
runningFoldIndexed
(
initial
:
R
,
operation
:
(
index
:
Int
,
acc
:
R
,
Char
)
->
R
)
:
List
<
R
>
runningReduce
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.
fun
CharSequence
.
runningReduce
(
operation
:
(
acc
:
Char
,
Char
)
->
Char
)
:
List
<
Char
>
runningReduceIndexed
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.
fun
CharSequence
.
runningReduceIndexed
(
operation
:
(
index
:
Int
,
acc
:
Char
,
Char
)
->
Char
)
:
List
<
Char
>
scan
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 initial value.
fun
<
R
>
CharSequence
.
scan
(
initial
:
R
,
operation
:
(
acc
:
R
,
Char
)
->
R
)
:
List
<
R
>
scanIndexed
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.
fun
<
R
>
CharSequence
.
scanIndexed
(
initial
:
R
,
operation
:
(
index
:
Int
,
acc
:
R
,
Char
)
->
R
)
:
List
<
R
>
single
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
singleOrNull
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
?
slice
split
Splits this char sequence to a list of strings around occurrences of the specified delimiters .
fun
CharSequence
.
split
(
vararg
delimiters
:
String
,
ignoreCase
:
Boolean
=
false
,
limit
:
Int
=
0
)
:
List
<
String
>
fun
CharSequence
.
split
(
vararg
delimiters
:
Char
,
ignoreCase
:
Boolean
=
false
,
limit
:
Int
=
0
)
:
List
<
String
>
Splits this char sequence to a list of strings around matches of the given regular expression.
fun
CharSequence
.
split
(
regex
:
Regex
,
limit
:
Int
=
0
)
:
List
<
String
>
Splits this char sequence around matches of the given regular expression.
fun
CharSequence
.
split
(
regex
:
Pattern
,
limit
:
Int
=
0
)
:
List
<
String
>
splitToSequence
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
>
Splits this char sequence to a sequence of strings around matches of the given regular expression.
fun
CharSequence
.
splitToSequence
(
regex
:
Regex
,
limit
:
Int
=
0
)
:
Sequence
<
String
>
startsWith
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
subSequence
Returns a subsequence of this char sequence.
fun
String
.
subSequence
(
start
:
Int
,
end
:
Int
)
:
CharSequence
Returns a subsequence of this char sequence specified by the given range of indices.
fun
CharSequence
.
subSequence
(
range
:
IntRange
)
:
CharSequence
substringAfter
Returns a substring after the first occurrence of delimiter . If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
substringAfter
(
delimiter
:
Char
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
substringAfter
(
delimiter
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
substringAfterLast
Returns a substring after the last occurrence of delimiter . If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
substringAfterLast
(
delimiter
:
Char
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
substringAfterLast
(
delimiter
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
substringBefore
Returns a substring before the first occurrence of delimiter . If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
substringBefore
(
delimiter
:
Char
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
substringBefore
(
delimiter
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
substringBeforeLast
Returns a substring before the last occurrence of delimiter . If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string.
fun
String
.
substringBeforeLast
(
delimiter
:
Char
,
missingDelimiterValue
:
String
=
this
)
:
String
fun
String
.
substringBeforeLast
(
delimiter
:
String
,
missingDelimiterValue
:
String
=
this
)
:
String
sumBy
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
sumByDouble
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
sumOf
Returns the sum of all values produced by selector function applied to each character in the char sequence.
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
Double
)
:
Double
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
Int
)
:
Int
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
Long
)
:
Long
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
UInt
)
:
UInt
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
ULong
)
:
ULong
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
BigDecimal
)
:
BigDecimal
fun
CharSequence
.
sumOf
(
selector
:
(
Char
)
->
BigInteger
)
:
BigInteger
take
Returns a string containing the first n characters from this string, or the entire string if this string is shorter.
fun
String
.
take
(
n
:
Int
)
:
String
takeLast
Returns a string containing the last n characters from this string, or the entire string if this string is shorter.
fun
String
.
takeLast
(
n
:
Int
)
:
String
takeLastWhile
Returns a string containing last characters that satisfy the given predicate .
fun
String
.
takeLastWhile
(
predicate
:
(
Char
)
->
Boolean
)
:
String
takeWhile
Returns a string containing the first characters that satisfy the given predicate .
fun
String
.
takeWhile
(
predicate
:
(
Char
)
->
Boolean
)
:
String
toBigDecimal
Parses the string as a java.math.BigDecimal number and returns the result.
fun
String
.
toBigDecimal
(
)
:
BigDecimal
fun
String
.
toBigDecimal
(
mathContext
:
MathContext
)
:
BigDecimal
toBigDecimalOrNull
Parses the string as a
java.math.BigDecimal
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toBigDecimalOrNull
(
)
:
BigDecimal
?
fun
String
.
toBigDecimalOrNull
(
mathContext
:
MathContext
)
:
BigDecimal
?
toBigInteger
Parses the string as a java.math.BigInteger number and returns the result.
fun
String
.
toBigInteger
(
)
:
BigInteger
fun
String
.
toBigInteger
(
radix
:
Int
)
:
BigInteger
toBigIntegerOrNull
Parses the string as a
java.math.BigInteger
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toBigIntegerOrNull
(
)
:
BigInteger
?
fun
String
.
toBigIntegerOrNull
(
radix
:
Int
)
:
BigInteger
?
toBooleanStrict
Returns
true
if the content of this string is equal to the word "true",
false
if it is equal to "false",
and throws an exception otherwise.
fun
String
.
toBooleanStrict
(
)
:
Boolean
toBooleanStrictOrNull
Returns
true
if the content of this string is equal to the word "true",
false
if it is equal to "false",
and
null
otherwise.
fun
String
.
toBooleanStrictOrNull
(
)
:
Boolean
?
toByteOrNull
Parses the string as a signed
Byte
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toByteOrNull
(
)
:
Byte
?
fun
String
.
toByteOrNull
(
radix
:
Int
)
:
Byte
?
toCharArray
Copies characters from this string into the destination character array and returns that array.
toCollection
Appends all characters to the given destination collection.
fun
<
C
:
MutableCollection
<
in
Char
>
>
CharSequence
.
toCollection
(
destination
:
C
)
:
C
toHashSet
Returns a new HashSet of all characters.
fun
CharSequence
.
toHashSet
(
)
:
HashSet
<
Char
>
toIntOrNull
Parses the string as an
Int
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toIntOrNull
(
)
:
Int
?
fun
String
.
toIntOrNull
(
radix
:
Int
)
:
Int
?
toList
Returns a List containing all characters.
fun
CharSequence
.
toList
(
)
:
List
<
Char
>
toLongOrNull
Parses the string as a
Long
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toLongOrNull
(
)
:
Long
?
fun
String
.
toLongOrNull
(
radix
:
Int
)
:
Long
?
toLowerCase
Returns a copy of this string converted to lower case using the rules of the specified locale.
fun
String
.
toLowerCase
(
locale
:
Locale
)
:
String
toMutableList
Returns a new MutableList filled with all characters of this char sequence.
fun
CharSequence
.
toMutableList
(
)
:
MutableList
<
Char
>
toRegex
Converts the string into a regular expression Regex with the default options.
fun
String
.
toRegex
(
)
:
Regex
Converts the string into a regular expression Regex with the specified single option .
fun
String
.
toRegex
(
option
:
RegexOption
)
:
Regex
Converts the string into a regular expression Regex with the specified set of options .
fun
String
.
toRegex
(
options
:
Set
<
RegexOption
>
)
:
Regex
toSet
Returns a Set of all characters.
fun
CharSequence
.
toSet
(
)
:
Set
<
Char
>
toShortOrNull
Parses the string as a
Short
number and returns the result
or
null
if the string is not a valid representation of a number.
fun
String
.
toShortOrNull
(
)
:
Short
?
fun
String
.
toShortOrNull
(
radix
:
Int
)
:
Short
?
toSortedSet
Returns a new SortedSet of all characters.
fun
CharSequence
.
toSortedSet
(
)
:
SortedSet
<
Char
>
toUpperCase
Returns a copy of this string converted to upper case using the rules of the specified locale.
fun
String
.
toUpperCase
(
locale
:
Locale
)
:
String
trim
Returns a string having leading and trailing characters matching the predicate removed.
fun
String
.
trim
(
predicate
:
(
Char
)
->
Boolean
)
:
String
Returns a string having leading and trailing characters from the chars array removed.
fun
String
.
trim
(
vararg
chars
:
Char
)
:
String
Returns a string having leading and trailing whitespace removed.
fun
String
.
trim
(
)
:
String
trimEnd
Returns a string having trailing characters matching the predicate removed.
fun
String
.
trimEnd
(
predicate
:
(
Char
)
->
Boolean
)
:
String
Returns a string having trailing characters from the chars array removed.
fun
String
.
trimEnd
(
vararg
chars
:
Char
)
:
String
Returns a string having trailing whitespace removed.
fun
String
.
trimEnd
(
)
:
String
trimIndent
Detects a common minimal indent of all the input lines, removes it from every line and also removes the first and the last lines if they are blank (notice difference blank vs empty).
fun
String
.
trimIndent
(
)
:
String
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
trimStart
Returns a string having leading characters matching the predicate removed.
fun
String
.
trimStart
(
predicate
:
(
Char
)
->
Boolean
)
:
String
Returns a string having leading characters from the chars array removed.
fun
String
.
trimStart
(
vararg
chars
:
Char
)
:
String
Returns a string having leading whitespace removed.
fun
String
.
trimStart
(
)
:
String
windowed
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
>
windowedSequence
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
>
withIndex
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.
fun
CharSequence
.
withIndex
(
)
:
Iterable
<
IndexedValue
<
Char
>
>
zip
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
>
zipWithNext
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
>
Companion Object Extension Functions
format
Uses the provided format as a format string and returns a string obtained by substituting format specifiers in the format string with the provided arguments, using the default locale.
fun
String.Companion
.
format
(
format
:
String
,
vararg
args
:
Any
?
)
:
String
Uses the provided
format
as a format string and returns a string obtained
by substituting format specifiers in the format string with the provided arguments,
using the specified locale. If
locale
is
null
then no localization is applied.
fun
String.Companion
.
format
(
locale
:
Locale
?
,
format
:
String
,
vararg
args
:
Any
?
)
:
String