Import std.text.string
std.text.string
A String's Methods, by byte position. A String is UTF-8: its Length is its bytes, and a position is a byte offset, which Find gives and Slice takes, so neither counts characters. A position outside the String, or inside one of its characters, panics. CharCount and GraphemeCount count its characters and what people see as one. The runtime's fb_text_ functions read the bytes, and its fb_unicode_ ones, over utf8proc, know Unicode's case and grapheme clusters.
std/text/string.fb
Types
LineIterator
struct
Public Struct LineIterator Implements Iterator<String>
A String's lines, one at a time, without their line breaks: "\n", "\r\n", or "\r".
-
The next line, or Null after the last one.
GraphemeIterator
struct
Public Struct GraphemeIterator Implements Iterator<String>
A String's grapheme clusters, one at a time, each a String.
-
The next grapheme cluster, or Null after the last one.
Extends
String
extend
Extend String
No doc comment.
-
How many bytes its UTF-8 has, which is also the position just past its end.
-
How many characters, code points, it has.
-
How many grapheme clusters it has: what people see as one character, like an "e" with its accent after it, or an emoji made of several.
-
A String of the UTF-8 in
bytes, or Null when they aren't well-formed UTF-8. -
Whether it has no characters.
-
Whether it has no characters but whitespace.
-
Whether
partis in it. Every String has "" in it. -
Whether
cis in it. -
Whether it starts with
prefix. -
Whether it ends with
suffix. -
Where
partfirst starts, at from or after, or Null when it isn't there. Panics when from isn't a position in the String. -
Where
partlast starts, or Null when it isn't there. -
Where
partlast starts that ends atbeforeor sooner, or Null when it isn't there. Panics whenbeforeisn't a position in the String. -
Where
partstarts, each time, from the start: after one is found, the next is looked for after its end. An emptypartpanics. -
How many times
partis in it, counting each from the end of the one before, as FindAll does. An emptypartpanics. -
The text from
startup tofinish. Panics unless both are positions in the String, between its characters, withstartno later thanfinish. -
The text before the first
part, or Null whenpartisn't there. -
The text after the first
part, or Null whenpartisn't there. -
The text before the first
separatorand after it, or Null whenseparatorisn't there. -
The parts between each separator: "a,,b" split by "," is "a", "", and "b". An empty
separatorpanics. -
The parts between each separator, at most
countof them, the last holding the rest. An emptyseparator, or a count below 1, panics. -
Its lines, without their line breaks: "\n", "\r\n", or "\r". A line break at the end makes no empty line after it, and an empty String has no lines.
-
Its words: the parts between runs of whitespace, which make no empty ones.
-
The
partswith this String between each two: ", ".Join(["a", "b"]) is "a, b". Panics past the most a String holds. -
A copy with each old, from the start, replaced by
replacement. An emptyoldpanics, and so does a copy past the most a String holds. -
A copy with the first
oldreplaced byreplacement, or the String itself whenoldisn't there. An emptyoldpanics. -
A copy without the whitespace at its start and end.
-
A copy without the whitespace at its start.
-
A copy without the whitespace at its end.
-
A copy without
prefixat its start, or the String itself when it doesn't start with it. -
A copy without
suffixat its end, or the String itself when it doesn't end with it. -
A copy in uppercase, by Unicode's full case mapping, so "straße" is "STRASSE". Panics past the most a String holds.
-
A copy in lowercase, by Unicode's full case mapping, with a capital sigma that ends a word as a final sigma: "ΣΑΣ" is "σας". Panics past the most a String holds.
-
The String
counttimes over, as std.core's Repeated gives a value. A negativecountpanics. -
A copy with
fillbefore it, as many as it takes to makewidthcharacters, or the String itself when it has as many already. Panics past the most a String holds. -
A copy with
fillafter it, as many as it takes to makewidthcharacters, or the String itself when it has as many already. Panics past the most a String holds. -
A copy with
fillon both sides, as many as it takes to makewidthcharacters, one more after it than before when they don't split evenly, or the String itself when it has as many already. Panics past the most a String holds. -
-1 when it comes before
other, 0 when they're equal, and 1 when it comes after, by their code points, as < compares them. -
Whether it's equal to
otherbut for case, as Unicode's case folding has it: "STRASSE" and "straße" are. Panics when both fold past the most a String holds, where one alone is longer than theother. -
-1, 0, or 1, as Compare gives, but with each run of the digits 0 to 9 compared as a number, so "file9" comes before "file10". Runs equal as numbers, like "07" and "7", go by their length after that, the shorter first.
-
Its lines, one at a time, as SplitLines gives them.
-
Its grapheme clusters, one at a time: what people see as one character each.
Report an issue with this page or with FutureBlitz on GitHub.