Package-level declarations

Types

Link copied to clipboard

Thrown when a portable JVM-style format string is malformed, lacks an argument, or uses an argument that is incompatible with its conversion.

Functions

Link copied to clipboard

Returns this string with suffix appended unless it already ends with suffix.

Link copied to clipboard

Returns a copy of this string with its first character converted to upper case.

Link copied to clipboard

Returns a copy of this string with the first character of every whitespace separated word converted to upper case.

Link copied to clipboard

Replaces every run of whitespace in this string with a single space and removes leading and trailing whitespace.

Link copied to clipboard
fun String.containsAll(vararg substrings: String, ignoreCase: Boolean = false): Boolean

Returns true when this string contains every element of substrings.

Link copied to clipboard
fun String.containsAny(vararg substrings: String, ignoreCase: Boolean = false): Boolean

Returns true when this string contains at least one element of substrings.

Link copied to clipboard

Counts the non-overlapping occurrences of substring in this string.

Link copied to clipboard

Returns a copy of this string with its first character converted to lower case.

Link copied to clipboard

Returns a copy of this string containing only its digit characters.

Link copied to clipboard

Returns the string without its first n lines. Dropping every line returns an empty string.

Link copied to clipboard
fun String.equalsAnyIgnoreCase(vararg candidates: String): Boolean

Returns true when this string equals at least one element of candidates, ignoring case.

Link copied to clipboard

Returns the content of this string before its first line break, or the whole string when it contains no line break.

Link copied to clipboard
fun String.format(vararg args: Any?): String

Uses this string as a JVM-style format string and substitutes args.

fun String.Companion.format(format: String, vararg args: Any?): String

Formats format with args using KiteCore's portable JVM-style formatter.

Link copied to clipboard
fun String.indent(spaces: Int): String

Prepends spaces space characters to every line of this string, including blank lines.

Link copied to clipboard
fun String.indexOfNth(substring: String, n: Int): Int

Returns the index of the nth non-overlapping occurrence of substring, where n counts from 1, or -1 when there are fewer than n occurrences.

Link copied to clipboard
fun String.initials(maxCount: Int = 2): String

Returns the upper cased first characters of up to maxCount whitespace separated words.

Link copied to clipboard

Returns true when this string is non-empty and every character is a letter.

Link copied to clipboard

Returns true when this string is non-empty and every character is a letter or a digit.

Link copied to clipboard

Returns true when this string is non-empty and every character is a hexadecimal digit (0-9, a-f, or A-F).

Link copied to clipboard

Returns true when this string is non-empty and every character is an ASCII digit.

Link copied to clipboard

Returns true when this character is one of the ASCII vowels a, e, i, o, or u, in either case.

Link copied to clipboard

Returns the content of this string after its last line break, or the whole string when it contains no line break.

Link copied to clipboard

Returns a copy of this string containing only its letter characters.

Link copied to clipboard

Returns the number of lines in this string, treating \n, \r\n, and \r as line breaks.

Link copied to clipboard
fun String.mask(visibleStart: Int = 0, visibleEnd: Int = 0, maskChar: Char = '*'): String

Replaces every character of this string with maskChar except the first visibleStart and the last visibleEnd characters.

Link copied to clipboard

Returns null when this string is blank, otherwise returns it unchanged.

Link copied to clipboard

Returns null when this string is empty, otherwise returns it unchanged.

Link copied to clipboard
fun String.padCenter(length: Int, padChar: Char = ' '): String

Pads this string on both sides with padChar so that the result is length characters long, keeping the original content centered.

Link copied to clipboard

Returns this string with prefix prepended unless it already starts with prefix.

Link copied to clipboard

Removes prefix from the start of this string, comparing case insensitively.

Link copied to clipboard

Removes suffix from the end of this string, comparing case insensitively.

Link copied to clipboard

Returns a copy of this string with every whitespace character removed.

Link copied to clipboard

Splits this string into its camel case segments.

Link copied to clipboard

Splits this string at the first occurrence of delimiter into the part before it and the part after it, or returns null when delimiter is absent.

Link copied to clipboard

Returns the substring after the first occurrence of start and before the next occurrence of end, or null when either delimiter is missing.

Link copied to clipboard

Returns the first n lines joined with a line feed. Fewer lines return the whole string.

Link copied to clipboard

Parses this string as a boolean, returning default when it matches neither value.

Link copied to clipboard

Converts this string to camelCase.

Link copied to clipboard

Parses this string as a Double, returning default when it is not a valid floating point number.

Link copied to clipboard

Parses this string as a Float, returning default when it is not a valid floating point number.

Link copied to clipboard
fun String.toIntOrDefault(default: Int): Int

Parses this string as a decimal Int, returning default when it is not a valid integer.

Link copied to clipboard

Converts this string to kebab-case.

Link copied to clipboard

Parses this string as a decimal Long, returning default when it is not a valid long integer.

Link copied to clipboard

Converts this string to PascalCase.

Link copied to clipboard

Converts this string to a lowercase ASCII slug.

Link copied to clipboard

Converts this string to snake_case.

Link copied to clipboard
fun String.truncate(maxLength: Int, ellipsis: String = "..."): String

Shortens this string to at most maxLength characters, replacing the removed tail with ellipsis.

Link copied to clipboard
fun String.truncateMiddle(maxLength: Int, ellipsis: String = "..."): String

Shortens this string to at most maxLength characters by removing a middle section and inserting ellipsis in its place.

Link copied to clipboard

Returns the number of bytes this string occupies when encoded as UTF-8, computed from its code points without allocating an encoded copy.

Link copied to clipboard
fun String.wrap(maxLineLength: Int): String

Word wraps this string so that no line exceeds maxLineLength characters where possible.