Exception, to be thrown when a call to advancePast went wrong.
Exception, to be thrown when a call to advancePast went wrong.
The result of a call to splitInto.
Given some string, finds the supplied needle token in it, returns the string up to that point, and advances the passed string by ref to after the token.
Base64-decodes a string.
Base64-encodes a string.
Replaces the control characters '\n', '\t', '\r' and '\0' with the escaped "\\n", "\\t", "\\r" and "\\0". Does not allocate a new string if there was nothing to escape.
Indents lines in a string with the supplied number of tabs. Returns a newly allocated string.
Indents lines in a string into an output range sink with the supplied number of tabs.
Selects the correct singular or plural form of a word depending on the numerical count of it.
Removes the control characters '\n', '\t', '\r' and '\0' from a string. Does not allocate a new string if there was nothing to remove.
Replaces space-separated tokens (that begin with a token character) in a string with values from a supplied associative array.
Splits a string by a passed separator and assign the delimited words to the passed strings by ref. Overload that stores overflow strings into a passed array.
Splits a string by a passed separator and assign the delimited words to the passed strings by ref.
Splits a string with on boundary as delimited by a supplied separator, into one or more more lines not longer than the passed maximum length.
Splits a string into an array of strings by whitespace, but honours quotes.
Strips the supplied string from the end of a string.
Returns a slice of the passed string with any preceding or trailing whitespace or linebreaks sliced off both ends. Overload that implicitly strips " \n\r\t".
Returns a slice of the passed string with any preceding or trailing passed characters sliced off. Implementation template capable of handling both individual characters and strings of tokens to strip.
Returns a slice of the passed string with any preceding whitespace and/or linebreaks sliced off. Overload that implicitly strips " \n\r\t".
Returns a slice of the passed string with any preceding passed characters sliced off. Implementation capable of handling both individual characters and strings of tokens to strip.
Returns a slice of the passed string with any trailing whitespace and/or linebreaks sliced off. Overload that implicitly strips " \n\r\t".
Returns a slice of the passed string with any trailing passed characters. Implementation template capable of handling both individual characters and string of tokens to strip.
Returns a range of *spaces* equal to that of num tabs (\t).
Removes paired preceding and trailing tokens around a string line. Assumes ASCII.
Removes paired preceding and trailing double quotes, unquoting a word. Assumes ASCII.
Removes paired preceding and trailing single quotes around a line. Assumes ASCII.
{ string line = "Lorem ipsum :sit amet"; immutable lorem = line.advancePast(" :"); assert(lorem == "Lorem ipsum", lorem); assert(line == "sit amet", line); } { string line = "Lorem ipsum :sit amet"; immutable lorem = line.advancePast(':'); assert(lorem == "Lorem ipsum ", lorem); assert(line == "sit amet", line); } { string line = "Lorem ipsum sit amet"; // mutable, will be modified by ref string[] words; while (line.length > 0) { immutable word = line.advancePast(" ", inherit: true); words ~= word; } assert(words == [ "Lorem", "ipsum", "sit", "amet" ]); }
String manipulation functions complementing the standard library.