std.string
concat function
pub fn concat(a: string, b: string): string
stdlib/std/string.lyr:14
fromInt function
pub fn fromInt(value: int): string
stdlib/std/string.lyr:16
fromUint function
pub fn fromUint(value: uint): string
stdlib/std/string.lyr:20
fromFloat function
pub fn fromFloat(value: float): string
stdlib/std/string.lyr:21
fromBool function
pub fn fromBool(value: bool): string
stdlib/std/string.lyr:22
fromChar function
pub fn fromChar(value: char): string
stdlib/std/string.lyr:23
repeat function
pub fn repeat(value: string, count: int): string
stdlib/std/string.lyr:27
length function
pub fn length(value: string): int
stdlib/std/string.lyr:37
charAt function
pub fn charAt(value: string, index: int): char
stdlib/std/string.lyr:38
substring function
pub fn substring(value: string, start: int, count: int): string
stdlib/std/string.lyr:39
indexOf function
pub fn indexOf(value: string, needle: string): int
stdlib/std/string.lyr:43
contains function
pub fn contains(value: string, needle: string): bool
stdlib/std/string.lyr:44
startsWith function
pub fn startsWith(value: string, prefix: string): bool
stdlib/std/string.lyr:45
endsWith function
pub fn endsWith(value: string, suffix: string): bool
stdlib/std/string.lyr:46
trim function
pub fn trim(value: string): string
stdlib/std/string.lyr:48
toUpper function
pub fn toUpper(value: string): string
stdlib/std/string.lyr:51
toLower function
pub fn toLower(value: string): string
stdlib/std/string.lyr:52
split function
pub fn split(value: string, separator: string): string[]
stdlib/std/string.lyr:55
toChars function
pub fn toChars(value: string): char[]
stdlib/std/string.lyr:58
isDigit function
pub fn isDigit(c: char): bool
stdlib/std/string.lyr:77
isAlpha function
pub fn isAlpha(c: char): bool
stdlib/std/string.lyr:82
isAlphanumeric function
pub fn isAlphanumeric(c: char): bool
stdlib/std/string.lyr:86
isWhitespace function
pub fn isWhitespace(c: char): bool
stdlib/std/string.lyr:90
isUpper function
pub fn isUpper(c: char): bool
stdlib/std/string.lyr:94
isLower function
pub fn isLower(c: char): bool
stdlib/std/string.lyr:98
charToDigit function
pub fn charToDigit(c: char): ?int
The numeric value of a digit, or null when it is not one.
?int rather than -1: a failure the caller has to handle belongs in the type.
stdlib/std/string.lyr:105
digitToChar function
pub fn digitToChar(value: int): ?char
stdlib/std/string.lyr:112
isEmpty function
pub fn isEmpty(value: string): bool
stdlib/std/string.lyr:121
isBlank function
pub fn isBlank(value: string): bool
Empty or whitespace only.
stdlib/std/string.lyr:126
indexOfFrom function
pub fn indexOfFrom(value: string, needle: string, start: int): int
Searches from a position. -1 when nothing is found, as in indexOf.
stdlib/std/string.lyr:141
lastIndexOf function
pub fn lastIndexOf(value: string, needle: string): int
The LAST occurrence.
stdlib/std/string.lyr:159
count function
pub fn count(value: string, needle: string): int
How often needle occurs, WITHOUT overlap.
Overlapping occurrences are not counted: count("aaa", "aa") is 1, not 2. This matches
replace.
stdlib/std/string.lyr:180
join function
pub fn join(parts: string[], separator: string): string
Joins the parts with a separator: the inverse of split.
stdlib/std/string.lyr:197
splitLines function
pub fn splitLines(value: string): string[]
Splits at line breaks. Both \r\n and \n count.
stdlib/std/string.lyr:212
splitFirst function
pub fn splitFirst(value: string, separator: string): string[]
Splits at the FIRST occurrence; the rest stays whole, for key=value=more.
stdlib/std/string.lyr:218
replace function
pub fn replace(value: string, needle: string, ersatz: string): string
stdlib/std/string.lyr:229
replaceFirst function
pub fn replaceFirst(value: string, needle: string, ersatz: string): string
stdlib/std/string.lyr:251
trimStart function
pub fn trimStart(value: string): string
stdlib/std/string.lyr:264
trimEnd function
pub fn trimEnd(value: string): string
stdlib/std/string.lyr:273
padStart function
pub fn padStart(value: string, width: int, fill: char): string
Pads at the front until width is reached. A longer string is left unchanged; truncating
would lose data in a function that only formats.
stdlib/std/string.lyr:283
padEnd function
pub fn padEnd(value: string, width: int, fill: char): string
stdlib/std/string.lyr:291
parseInt function
pub fn parseInt(value: string): ?int
"-42" becomes -42, anything else null.
No overflow protection: a number beyond int64 wraps rather than yielding null. Detecting
it would need a division per digit.
stdlib/std/string.lyr:308
parseIntRadix function
pub fn parseIntRadix(value: string, radix: int): ?int
From a base of 2 to 36. Letters continue from a/A.
stdlib/std/string.lyr:341
parseBool function
pub fn parseBool(value: string): ?bool
stdlib/std/string.lyr:384
parseFloat function
pub fn parseFloat(value: string): ?float
"3.5", "-0.25" and "42" become floating point; everything else is null.
Without exponent notation (1e9), which would need a state machine of its own.
stdlib/std/string.lyr:397
fromChars function
pub fn fromChars(chars: char[]): string
stdlib/std/string.lyr:453
StringBuilder class
pub class StringBuilder
Builds a string piece by piece.
s = s + part in a loop is quadratic: every step copies the whole string so far. The builder
collects the parts and joins them once.
The backing is a doubling string[], written by hand because this module must not import
std.collections.
parts: string[]
count: int
pub fn length(): int
pub mut fn append(value: string): void
pub mut fn appendLine(value: string): void
pub mut fn appendChar(value: char): void
pub fn build(): string
stdlib/std/string.lyr:470
newStringBuilder function
pub fn newStringBuilder(): StringBuilder
stdlib/std/string.lyr:512