Package-level declarations

Functions for working with text and regular expressions.

Types

Link copied to clipboard
Since Kotlin 1.0
Link copied to clipboard

Represents the Unicode directionality of a character. Character directionality is used to calculate the visual ordering of text.

Since Kotlin 1.0
Link copied to clipboard
object Charsets

Constant definitions for the standard charsets. These charsets are guaranteed to be available on every implementation of the Java platform.

Since Kotlin 1.0
Link copied to clipboard
actual data class MatchGroup(val value: String, val range: IntRange)

Represents the results from a single capturing group within a MatchResult of Regex.

Since Kotlin 1.0
Link copied to clipboard
actual class Regex : Serializable

Represents a compiled regular expression. Provides functions to match strings in text with a pattern, replace the found occurrences and split text around matches.

Since Kotlin 1.0
Link copied to clipboard
actual enum RegexOption : Enum<RegexOption> , FlagEnum

Provides enumeration values to use to set regular expression options.

Since Kotlin 1.0

Functions

Link copied to clipboard
fun Appendable.appendln(): Appendable

Appends a line separator to this Appendable.

Since Kotlin 1.0
fun StringBuilder.appendln(): StringBuilder

Appends a line separator to this StringBuilder.

Since Kotlin 1.0
inline fun Appendable.appendln(value: Char): Appendable
inline fun Appendable.appendln(value: CharSequence?): Appendable

Appends value to the given Appendable and line separator after it.

Since Kotlin 1.0
inline fun StringBuilder.appendln(value: StringBuffer?): StringBuilder
inline fun StringBuilder.appendln(value: StringBuilder?): StringBuilder
inline fun StringBuilder.appendln(value: Any?): StringBuilder
inline fun StringBuilder.appendln(value: Boolean): StringBuilder
inline fun StringBuilder.appendln(value: Byte): StringBuilder
inline fun StringBuilder.appendln(value: Char): StringBuilder
inline fun StringBuilder.appendln(value: CharArray): StringBuilder
inline fun StringBuilder.appendln(value: CharSequence?): StringBuilder
inline fun StringBuilder.appendln(value: Double): StringBuilder
inline fun StringBuilder.appendln(value: Float): StringBuilder
inline fun StringBuilder.appendln(value: Int): StringBuilder
inline fun StringBuilder.appendln(value: Long): StringBuilder
inline fun StringBuilder.appendln(value: Short): StringBuilder
inline fun StringBuilder.appendln(value: String?): StringBuilder

Appends value to this StringBuilder, followed by a line separator.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.capitalize(): String

Returns a copy of this string having its first letter titlecased using the rules of the default locale, or the original string if it's empty or already starts with a title case letter.

Since Kotlin 1.0
Link copied to clipboard
inline fun charset(charsetName: String): Charset

Returns a named charset with the given charsetName name.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.codePointAt(index: Int): Int

Returns the character (Unicode code point) at the specified index.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.codePointBefore(index: Int): Int

Returns the character (Unicode code point) before the specified index.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.codePointCount(beginIndex: Int, endIndex: Int): Int

Returns the number of Unicode code points in the specified text range of this String.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.compareTo(other: String, ignoreCase: Boolean = false): Int

Compares two strings lexicographically, optionally ignoring case differences.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.contentEquals(stringBuilder: StringBuffer): Boolean

Returns true if this string is equal to the contents of the specified StringBuffer, false otherwise.

Since Kotlin 1.0
inline fun String.contentEquals(charSequence: CharSequence): Boolean

Returns true if this string is equal to the contents of the specified CharSequence, false otherwise.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.decapitalize(): String

Returns a copy of this string having its first letter lowercased using the rules of the default locale, or the original string if it's empty or already starts with a lower case letter.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun CharSequence.elementAt(index: Int): Char

Returns a character at the given index or throws an IndexOutOfBoundsException if the index is out of bounds of this char sequence.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean

Returns true if this string ends with the specified suffix.

Since Kotlin 1.0
Link copied to clipboard
actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean

Returns true if this string is equal to other, optionally ignoring character case.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.format(vararg args: Any?): String

Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the default locale.

Since Kotlin 1.0
inline fun String.format(locale: Locale, vararg args: Any?): String

Uses this string as a format string and returns a string obtained by substituting the specified arguments, using the specified locale.

Since Kotlin 1.0
inline 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 the specified arguments, using the default locale.

Since Kotlin 1.0
inline fun String.Companion.format(locale: Locale, format: String, vararg args: Any?): String

Uses the provided format as a format string and returns a string obtained by substituting the specified arguments, using the specified locale.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.intern(): String

Returns a canonical representation for this string object.

Since Kotlin 1.0
Link copied to clipboard

Returns true if this string is empty or consists solely of whitespace characters.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isDefined(): Boolean

Returns true if this character (Unicode code point) is defined in Unicode.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isDigit(): Boolean

Returns true if this character is a digit.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isHighSurrogate(): Boolean

Returns true if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit).

Since Kotlin 1.0
Link copied to clipboard

Returns true if this character (Unicode code point) should be regarded as an ignorable character in a Java identifier or a Unicode identifier.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isISOControl(): Boolean

Returns true if this character is an ISO control character.

Since Kotlin 1.0
Link copied to clipboard

Returns true if this character (Unicode code point) may be part of a Java identifier as other than the first character.

Since Kotlin 1.0
Link copied to clipboard

Returns true if this character is permissible as the first character in a Java identifier.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isLetter(): Boolean

Returns true if this character is a letter.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isLetterOrDigit(): Boolean

Returns true if this character is a letter or digit.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isLowerCase(): Boolean

Returns true if this character is lower case.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isLowSurrogate(): Boolean

Returns true if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit).

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isTitleCase(): Boolean

Returns true if this character is a title case letter.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.isUpperCase(): Boolean

Returns true if this character is upper case.

Since Kotlin 1.0
Link copied to clipboard
actual fun Char.isWhitespace(): Boolean

Determines whether a character is whitespace according to the Unicode standard. Returns true if the character is whitespace.

Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.0
Link copied to clipboard
inline fun <R : Comparable<R>> CharSequence.maxBy(selector: (Char) -> R): Char?
Since Kotlin 1.0
Link copied to clipboard
fun CharSequence.maxWith(comparator: Comparator<in Char>): Char?
Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.0
Link copied to clipboard
inline fun <R : Comparable<R>> CharSequence.minBy(selector: (Char) -> R): Char?
Since Kotlin 1.0
Link copied to clipboard
fun CharSequence.minWith(comparator: Comparator<in Char>): Char?
Since Kotlin 1.0
Link copied to clipboard
inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int

Returns the index within this string that is offset from the given index by codePointOffset code points.

Since Kotlin 1.0
Link copied to clipboard
actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean

Returns true if the specified range in this char sequence is equal to the specified range in another char sequence.

Since Kotlin 1.0
fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean

Returns true if the specified range in this string is equal to the specified range in another string.

Since Kotlin 1.0
Link copied to clipboard
actual fun CharSequence.repeat(n: Int): String

Returns a string containing this char sequence repeated n times.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String

Returns a new string with all occurrences of oldChar replaced with newChar.

Since Kotlin 1.0
actual fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String

Returns a new string obtained by replacing all occurrences of the oldValue substring in this string with the specified newValue string.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String

Returns a new string with the first occurrence of oldChar replaced with newChar.

Since Kotlin 1.0
actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String

Returns a new string obtained by replacing the first occurrence of the oldValue substring in this string with the specified newValue string.

Since Kotlin 1.0
Link copied to clipboard
actual inline operator fun StringBuilder.set(index: Int, value: Char)

Sets the character at the specified index to the specified value.

Since Kotlin 1.0
Link copied to clipboard
fun CharSequence.split(regex: Pattern, limit: Int = 0): List<String>

Splits this char sequence around matches of the given regular expression.

Since Kotlin 1.0
Link copied to clipboard
actual fun String.startsWith(prefix: String, ignoreCase: Boolean = false): Boolean

Returns true if this string starts with the specified prefix.

Since Kotlin 1.0
actual fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean = false): Boolean

Returns true if a substring of this string starting at the specified offset startIndex starts with the specified prefix.

Since Kotlin 1.0
Link copied to clipboard
inline fun String(stringBuffer: StringBuffer): String

Converts the contents of the specified StringBuffer to a string.

Since Kotlin 1.0
inline fun String(stringBuilder: StringBuilder): String

Converts the contents of the specified StringBuilder to a string.

Since Kotlin 1.0
inline fun String(bytes: ByteArray): String

Converts the data from the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string.

Since Kotlin 1.0
actual inline fun String(chars: CharArray): String

Converts the characters in the specified array to a string.

Since Kotlin 1.0
inline fun String(bytes: ByteArray, charset: Charset): String

Converts the data from the specified array of bytes to characters using the specified character set and returns the conversion result as a string.

Since Kotlin 1.0
inline fun String(bytes: ByteArray, offset: Int, length: Int): String

Converts the data from a portion of the specified array of bytes to characters using the UTF-8 character set and returns the conversion result as a string.

Since Kotlin 1.0
actual inline fun String(chars: CharArray, offset: Int, length: Int): String

Converts the characters from a portion of the specified array to a string.

Since Kotlin 1.0
inline fun String(codePoints: IntArray, offset: Int, length: Int): String

Converts the code points from a portion of the specified Unicode code point array to a string.

Since Kotlin 1.0
inline fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String

Converts the data from a portion of the specified array of bytes to characters using the specified character set and returns the conversion result as a string.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.substring(startIndex: Int): String

Returns a substring of this string that starts at the specified startIndex and continues to the end of the string.

Since Kotlin 1.0
actual inline fun String.substring(startIndex: Int, endIndex: Int): String

Returns the substring of this string starting at the startIndex and ending right before the endIndex.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toBoolean(): Boolean

Returns true if the content of this string is equal to the word "true", ignoring case, and false otherwise.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toByte(): Byte

Parses the string as a signed Byte number and returns the result.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.toByteArray(charset: Charset = Charsets.UTF_8): ByteArray

Encodes the contents of this string using the specified character set and returns the resulting byte array.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toCharArray(): CharArray

Returns a CharArray containing characters of this string.

Since Kotlin 1.0
inline fun String.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = length): CharArray

Copies characters from this string into the destination character array and returns that array.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toDouble(): Double

Parses the string as a Double number and returns the result.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toFloat(): Float

Parses the string as a Float number and returns the result.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toInt(): Int

Parses the string as an Int number and returns the result.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toLong(): Long

Parses the string as a Long number and returns the result.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.toLowerCase(): Char

Converts this character to lower case using Unicode mapping rules of the invariant locale.

Since Kotlin 1.0
actual inline fun String.toLowerCase(): String

Returns a copy of this string converted to lower case using the rules of the default locale.

Since Kotlin 1.0
inline fun String.toLowerCase(locale: Locale): String

Returns a copy of this string converted to lower case using the rules of the specified locale.

Since Kotlin 1.0
Link copied to clipboard
inline fun String.toPattern(flags: Int = 0): Pattern

Converts the string into a regular expression Pattern optionally with the specified flags from Pattern or'd together so that strings can be split or matched on.

Since Kotlin 1.0
Link copied to clipboard
inline fun Pattern.toRegex(): Regex

Converts this java.util.regex.Pattern to an instance of Regex.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun String.toShort(): Short

Parses the string as a Short number and returns the result.

Since Kotlin 1.0
Link copied to clipboard

Returns a new SortedSet of all characters.

Since Kotlin 1.0
Link copied to clipboard
inline fun Char.toTitleCase(): Char

Converts this character to title case using Unicode mapping rules of the invariant locale.

Since Kotlin 1.0
Link copied to clipboard
actual inline fun Char.toUpperCase(): Char

Converts this character to upper case using Unicode mapping rules of the invariant locale.

Since Kotlin 1.0
actual inline fun String.toUpperCase(): String

Returns a copy of this string converted to upper case using the rules of the default locale.

Since Kotlin 1.0
inline fun String.toUpperCase(locale: Locale): String

Returns a copy of this string converted to upper case using the rules of the specified locale.

Since Kotlin 1.0

Properties

Link copied to clipboard

A Comparator that orders strings ignoring character case.

Since Kotlin 1.0
Link copied to clipboard

Returns the Unicode general category of this character.

Since Kotlin 1.0
Link copied to clipboard

Returns the Unicode directionality property for the given character.

Since Kotlin 1.0