Exception, to be thrown when a call to advancePast went wrong.
Exception, to be thrown when a call to advancePast went wrong. This is the templated implementation, so that we can support more than one kind of needle and haystack combination.
The result of a call to splitInto.
Given a reference to some string, finds the supplied needle token in it, returns the string up to that point, and advances the passed ref string to after the token.
Base64-decodes a string.
Base64-encodes a string.
Replaces the control characters '\n', '\t', '\r' and '\0' in a string 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 space-based tabs. Returns a newly-allocated string.
Indents lines in a string into an output range sink with the supplied number of space-based tabs.
Returns the singular or plural form of a word based on a numeric value.
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 words that begin with a token character in a string that match keys in a supplied associative array. The associative array values must be of some callable type of function or delegate returning strings.
Splits a string by a passed separator and assign the delimited words to the passed ref strings. Overload that stores overflow strings into a passed array.
Splits a string by a passed separator and assigns the delimited words to the passed ref strings.
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.