String
classin packageklyn
public final class String
String
Properties
Modifier and Type Member Description
public readonly property codePoints
codePoints as Char[]
Returns a snapshot of the Unicode scalar values in this string.
public readonly property codeUnits
codeUnits as CodeUnit[]
Returns a snapshot of this string encoded as UTF-16 code units.
public readonly property isEmpty
isEmpty as Boolean
Returns true if the string is empty.
public readonly native property size
size as ULong
Returns the number of Unicode scalar values in the string.
Constructors
Modifier and Type Member Description
public String Builds the empty string.
public String
String(notnull value as Char[])
Builds a string from Unicode scalar values.
public String
String(notnull value as CodeUnit[])
Builds a string from an array of UTF-16 code units.
public String
String(value as Char)
Builds a one-scalar string from a Char.
public String
String(value as CodeUnit)
Builds a one-character string from a CodeUnit.
public String
String(value as Object)
Builds a string from any object by using its textual representation.
Methods
Modifier and Type Member Description
public native static _slice
_slice(text as String, start as Long, stop as Long, sliceStep as Long, hasStart as Boolean, hasStop as Boolean) as String
Internal helper used by the compiler to implement slice syntax.
public center
center(width as Long, fill as Char = ' ') as String
Centers this string to the target width.
public count
count(value as Char) as ULong
Counts occurrences of a Unicode scalar in one forward traversal.
public count
count(value as String) as ULong
Counts non-overlapping occurrences of a text fragment.
public endsWith
endsWith(suffix as Char) as Boolean
Tests whether the last Unicode scalar equals the given character.
public endsWith
endsWith(suffix as Object) as Boolean
Returns true if this string ends with the provided value.
public endsWith
endsWith(suffixes as IList<String>) as Boolean
Returns true if this string ends with at least one suffix from the provided list.
public native endsWith
endsWith(suffix as String) as Boolean
Returns true if this string ends with the provided suffix.
public equalsIgnoreCase
equalsIgnoreCase(other as String) as Boolean
Compares two strings without case sensitivity.
public static fromCodePoint
fromCodePoint(value as Int) as String
Builds a string from one Unicode scalar value.
public static fromCodePoint
fromCodePoint(value as UInt) as String
Builds an immutable string containing an unsigned Unicode scalar value.
public native override hash
hash() as Long
Returns a content-based hash compatible with String equality.
public indexOf
indexOf(value as Char, start as Long = 0) as Long
Finds the first occurrence of a Unicode character.
public native indexOf
indexOf(value as String, start as Long = 0) as Long
Finds the first index of a text fragment starting from a position.
public isAlnum
isAlnum() as Boolean
Returns true if all characters are Unicode letters or digits.
public isAlpha
isAlpha() as Boolean
Returns true if all characters are Unicode alphabetic characters.
public isBlank
isBlank() as Boolean
Returns true if the string is empty or only contains spaces.
public isDigit
isDigit() as Boolean
Returns true if all characters are Unicode digits.
public isLower
isLower() as Boolean
Returns true if all cased characters are lowercase and at least one cased character exists.
public isSpace
isSpace() as Boolean
Returns true if all characters are whitespace.
public isUpper
isUpper() as Boolean
Returns true if all cased characters are uppercase and at least one cased character exists.
public join
join(values as Array<Char>) as String
Joins an array of Unicode scalar values using this string as separator.
public join
join(values as Array<CodeUnit>) as String
Joins an array of UTF-16 code units using this string as separator.
public join
join(values as Array<String>) as String
Joins an array of strings using this string as separator.
public join
join(values as IList<String>) as String
Joins a list of strings using this string as separator.
public lastIndexOf
lastIndexOf(value as Char, start as Long = -1) as Long
Finds the last occurrence of a Unicode character.
public native lastIndexOf
lastIndexOf(value as String, start as Long = -1) as Long
Finds the last index of a text fragment up to a position.
public lines
lines() as ArrayList<String>
Splits this string into lines without keeping line terminators.
public lpad
lpad(width as Long, fill as Char = ' ') as String
Left pads this string to the target width.
public matches Tests the string against a regular expression.
public native removeSGR
removeSGR(compatibility as String = "") as String
Returns the string with ANSI SGR escape sequences removed.
public native replace
replace(oldValue as String, newValue as String) as String
Returns a copy where all occurrences of oldValue are replaced by newValue.
public replace
replace(notnull oldValue as String, newValue as Char) as String
Replaces every non-overlapping text occurrence with one scalar.
public replace
replace(oldValue as Char, newValue as Char) as String
Replaces every occurrence of one Unicode scalar with another.
public replace
replace(oldValue as Char, notnull newValue as String) as String
Replaces every occurrence of a Unicode scalar with immutable text.
public native replaceFirst
replaceFirst(oldValue as String, newValue as String) as String
Returns a copy where the first occurrence of oldValue is replaced by newValue.
public replaceFirst
replaceFirst(notnull oldValue as String, newValue as Char) as String
Replaces the first text occurrence with one scalar.
public replaceFirst
replaceFirst(oldValue as Char, newValue as Char) as String
Replaces the first occurrence of one Unicode scalar with another.
public replaceFirst
replaceFirst(oldValue as Char, notnull newValue as String) as String
Replaces the first occurrence of a Unicode scalar with text.
public native replaceLast
replaceLast(oldValue as String, newValue as String) as String
Returns a copy where the last occurrence of oldValue is replaced by newValue.
public replaceLast
replaceLast(notnull oldValue as String, newValue as Char) as String
Replaces the last text occurrence with one scalar.
public replaceLast
replaceLast(oldValue as Char, newValue as Char) as String
Replaces the last occurrence of one Unicode scalar with another.
public replaceLast
replaceLast(oldValue as Char, notnull newValue as String) as String
Replaces the last occurrence of a Unicode scalar with text.
public rpad
rpad(width as Long, fill as Char = ' ') as String
Right pads this string to the target width.
public native split
split(delimiter as String) as ArrayList<String>
Splits the string using a string delimiter.
public split
split(delimiter as Char) as ArrayList<String>
Splits text at a Unicode scalar using the same rules as split(String).
public native startsWith
startsWith(prefix as String) as Boolean
Returns true if this string starts with the provided prefix.
public startsWith
startsWith(prefix as Char) as Boolean
Tests whether the first Unicode scalar equals the given character.
public startsWith
startsWith(prefix as Object) as Boolean
Returns true if this string starts with the provided value.
public startsWith
startsWith(prefixes as IList<String>) as Boolean
Returns true if this string starts with at least one prefix from the provided list.
public native toCapitalize
toCapitalize() as String
Returns a new string with the first character capitalized.
public toCharArray
toCharArray() as Char[]
Copies this text into an array of Unicode scalar values.
public native toCodeUnitArray
toCodeUnitArray() as CodeUnit[]
Encodes this text as UTF-16 code units.
public native toLower
toLower() as String
Returns the string in lowercase.
public native toRemoveAccents
toRemoveAccents() as String
Returns a new string without accents.
public override toString
toString() as String
Returns this string (identity conversion).
public native toTitle
toTitle() as String
Returns a title-cased copy of this string.
public toTrim
toTrim() as String
Returns the string with leading and trailing whitespace removed.
public native toUpper
toUpper() as String
Returns the string in uppercase.
Operators
Modifier and Type Member Description
public native static operator*( readonly first as String, readonly count as ULong ) as String Repeats a string a given number of times.
public native operator*=( readonly count as ULong ) as String Repeats text and rebinds the compound-assignment target.
public native static operator+( readonly first as String, readonly second as String ) as String Concatenates two strings.
public native operator+=( readonly second as String ) as String Concatenates text and rebinds the compound-assignment target.
public native operator[]( position as Long ) as Char throws IndexException Returns or sets the Unicode scalar at the given position.