For The String class represents character strings. to each character with its index in the original char sequence and current accumulator value. Returns a list containing only the non-null results of applying the given transform function Returns the single character matching the given predicate, or null if character was not found or more than one character was found. Returns true if this nullable char sequence is either null or empty. Returns index of the last character matching the given predicate, or -1 if the char sequence does not contain such character. Removes the part of a string at the given range. Returns the smallest character or null if there are no characters. Finds the index of the first occurrence of any of the specified chars in this char sequence, Powered by Discourse, best viewed with JavaScript enabled, return lines map { it.replaceAll("^\s*|", “”) } join “n”, Multiline string literal indent handling is unconvient, https://eclipse.org/xtend/documentation/203_xtend_expressions.html#templates, https://youtrack.jetbrains.com/issue/KT-17755. Returns a new character sequence that is a subsequence of this character sequence, Ensures that this value lies in the specified range. by the key returned by the given keySelector function applied to the character If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string. snapshot is a string. starting from the specified startIndex and optionally ignoring the case. Otherwise returns this string unchanged. Returns a single list of all elements yielded from results of transform function being invoked on each character of original char sequence. Accumulates value starting with initial value and applying operation from left to right If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string. and its index in the original char sequence, to the given destination. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string. Prepends indent to every line of the original string. Returns a string with the last n characters removed. or null if the string is not a valid representation of a number. among all values produced by selector function applied to each character in the char sequence. an each char sequence representing a view over the window of the given size Xtend has solved this really nicely: Creates a range from this Comparable value to the specified that value. to each character in the original char sequence. Applies the given transform function to each character of the original char sequence Returns the number of characters matching the given predicate. If these functions could now be defined as constexpr and evaluated at compile time your problem would go away. Splits this char sequence into a list of strings each not exceeding the given size. Returns a random character from this char sequence using the specified source of randomness. Otherwise returns this string unchanged. and value is provided by the valueTransform function applied to characters of the given char sequence. and puts to the destination map each group key associated with a list of corresponding values. Converts the string into a regular expression Regex with the specified single option. taking care not to split surrogate pairs. sliding along this char sequence with the given step. Replaces invalid input sequences with a default character. Appends all elements yielded from results of transform function being invoked on each character Returns true if this char sequence contains the specified character char. Returns a list of pairs of each two adjacent characters in this char sequence. Returns a string having trailing whitespace removed. Removes the given delimiter string from both the start and the end of this string Returns the character (Unicode code point) at the specified index. provided by transform function applied to each character of the given char sequence. Returns a string having trailing characters from the chars array removed. and appends the results to the given destination. starting from the specified startIndex and optionally ignoring the case. Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to characters of the given char sequence. The “solution” is in the String.trim... functions that you can use to trim as desired. If this string starts with the given prefix, returns a copy of this string using the default locale. Returns a string containing all characters except first characters that satisfy the given predicate. Populates and returns the destination mutable map with key-value pairs for each character of the given char sequence, the trimming can’t be done at compile time, because Kotlin doesn’t know if name contains line breaks. Finds the index of the first occurrence of any of the specified strings in this char sequence, to each character and current accumulator value. where key is provided by the keySelector function applied to each character of the given char sequence applied to each character in the char sequence or null if there are no characters. 1 Kotlin String 1.0.1 Important Properties and Functions of Kotlin String 1.0.2 Accessing Characters in a String 1.0.3 Escape characters in Kotlin Strings 1.1 String Templates 1.2 Raw Strings – Multiline String 1.3 Overriding String Would be very nice to have such a functionality. with the result of the given function transform that takes MatchResult and returns a string to be used as a Returns the first character having the smallest value according to the provided comparator or null if there are no characters. Returns the index within this char sequence of the last occurrence of the specified character, using the provided transform function applied to each pair of characters. Kotlinの標準入力の方法を2つご紹介しました。 1つ目はmain関数の引数に渡す方法、 2つ目はreadLine関数を使う方法でした。 readLine関数はJavaのBufferedReaderを内部的に使用しており、 String?型が返ってくることを想定して入力の Appends all characters not matching the given predicate to the given destination. Returns true if the char sequence has no characters. Returns a string having leading characters matching the predicate removed. Regular expressions are instances of the kotlin.text.Regex class. Returns a string containing all characters except last characters that satisfy the given predicate. or null if the string is not a valid representation of a number. Replace part of string before the first occurrence of given delimiter with the replacement string. Accumulates value starting with the last character and applying operation from right to left Returns a string having leading and trailing whitespace removed. Yes I see how the current implementation can break existing code. Returns a string containing the last n characters from this string, or the entire string if this string is shorter. lines if they are blank (notice difference blank vs empty). Returns the sum of all values produced by selector function applied to each character in the char sequence. It would be nice to have a way to tell the compiler to do it at compile time. Returns the first character yielding the largest value of the given function or null if there are no characters. }. The nice thing about standard libraries is that functions from it can be replaced by intrinsics if so desired. It may also be possible to translate the dynamic bits of the string into a call that is wrapped in its own trim function that can is given the needed information for correct wrapping by the compiler. Returns the first character, or null if the char sequence is empty. or null if the string is not a valid representation of a number. Creates a Grouping source from a char sequence to be used later with one of group-and-fold operations applied to characters of the given char sequence. Returns single character, or null if the char sequence is empty or has more than one character. Kotlin Android TextView and ExitText Example. Removes the part of a string at a given range. Returns true if this char sequence contains the specified other sequence of characters as a substring. to each character, its index in the original char sequence and current accumulator value that starts with initial value. Returns a random character from this char sequence, or null if this char sequence is empty. If the string does not contain the delimiter, returns missingDelimiterValue which defaults to the original string. Appends all characters matching the given predicate to the given destination. sliding along this char sequence with the given step, where each Pads the string to the specified length at the end with the specified character or space.   |bananas, kiwis, using the default locale. Enjoy the benefits of a rich ecosystem with a wide range of community libraries. Trims leading whitespace characters followed by marginPrefix from every line of a source string and removes Kotlin - Split String to Lines - To split string to lines in Kotlin programming, you may use String.lines() function. = null, text: String?   return lines map { it.replaceAll("^\s*|", “”) } join “n” If this and other have no common prefix, returns the empty string. Intriniscs only work for constant strings, which is not that useful. to each character, its index in the original char sequence and current accumulator value that starts with the first character of this char sequence. = null, hint: String? Finds the first occurrence of any of the specified strings in this char sequence, Applies the given transform function to each character and its index in the original char sequence Fortunately, Kotlin has this handled as well. Returns true if a substring of this char sequence starting at the specified offset startIndex starts with the specified prefix. Applies the given transform function to each character in the original char sequence Returns a list of snapshots of the window of the given size The String class represents character strings. Returns a list of pairs built from the characters of this and the other char sequences with the same index https://eclipse.org/xtend/documentation/203_xtend_expressions.html#templates. the first and the last lines if they are blank (notice difference blank vs empty). Returns a Map containing key-value pairs provided by transform function I’m not a fan of Fantom’s approach, but I would like to see something like Scala`s stripMargin in the standard library. Parses the string as an ULong number and returns the result Groups values returned by the valueTransform function applied to each character of the original char sequence So if you’re debugging this code, and you want to log the exact query string, or copy paste it into an sqlite3 (or your SQL client of choice) to play around with it, it’s going to be ugly. Ensures that this value is not less than the specified minimumValue. Maybe something like this would be good enough for you? Parses the string as an UInt number and returns the result. In many use cases, the developer will know whether to expect line breaks in the dynamic parts, and can choose accordingly. } Parses the string as a ULong number and returns the result. to current accumulator value and each character with its index in the original char sequence. Returns the index within this char sequence of the first occurrence of the specified string, and appends the results to the given destination. I don’t have real numbers for this but I’d imagine that in most cases a multiline string in a dynamic trimMargin is just a bug and not intended, so maybe changing this is not as bad of a breaking change than it seems. Returns a string having trailing characters matching the predicate removed. Returns the longest string suffix such that this char sequence and other char sequence both end with this suffix, Returns a Map where keys are characters from the given char sequence and values are See Packages. Populates and returns the destination mutable map with key-value pairs,   val lines = this.split(“n”) produced by the valueSelector function applied to each character. Returns true if this char sequence ends with the specified suffix. Returns true if this char sequence is empty (contains no characters). Their API’s are kind of frozen by default anyway. Parses the string as an UShort number and returns the result Parses the string as an UInt number and returns the result to current accumulator value and each character with its index in the original char sequence. Uses the provided format as a format string and returns a string obtained by substituting the specified arguments, Appends all elements yielded from results of transform function being invoked on each character of original char sequence, to the given destination. Converts the string into a regular expression Pattern optionally Returns a new MutableList filled with all characters of this char sequence. using the specified locale. Literals of the kotlin string are implemented as instances of this type. Accumulates value starting with initial value and applying operation from right to left Correct me if I’m wrong but I don’t think tirmMargin or trimIndent are ever used with dynamic multiline strings. Returns true if this CharSequence has Unicode surrogate pair at the specified index. Kotlin 1.3.40 will actually support intrinsics for these functions, see https://youtrack.jetbrains.com/issue/KT-17755. into an IndexedValue containing the index of that character and the character itself. The returned list has length of the shortest char sequence. or null if the string is not a valid representation of a number. Splits this char sequence into several char sequences each not exceeding the given size Uses this string as a format string and returns a string obtained by substituting the specified arguments, Returns a lazy Iterable that wraps each character of the original char sequence The function lines() : splits the char sequence to a list of lines delimited by any of the following character sequences: Carriage-Return Line-Feed, Line-Feed or Carriage-Return. or null if the string is not a valid representation of a number. A Kotlin API for generating .kt source files. among all values produced by selector function applied to each character in the char sequence or null if there are no characters. to each character with its index in the original char sequence and current accumulator value. Populates and returns the destination mutable map with key-value pairs, Returns a copy of this string converted to lower case using the rules of the specified locale. Using compareTo() extension function Kotlin provides compareTo() extension function to String. This create a very strange code or a very strange string. using the specified locale. Replace part of string before the last occurrence of given delimiter with the replacement string. snapshot is a string. Help is never far away – consult extensive community resources Returns true if this char sequence ends with the specified character. Returns a string having leading and trailing characters from the chars array removed. EditText Multiline