15. Boost package for string manipulation library
The STRINGS boost module implements collection of helper macros and functions to accompany STRINGS.
All functions and symbols are in “strings_boost” module, use require to get access to it.
require daslib/strings_boost
15.1. Split and join
split (text: string implicit; delim: string implicit) : array<string>
split_by_chars (text: string implicit; delim: string implicit) : array<string>
join (var it: iterator<auto(TT)>; separator: string implicit) : auto
split (text: string implicit; delim: string implicit; blk: block<(arg:array<string>#):auto>) : auto
- split(text: string implicit; delim: string implicit) : array<string>()
Splits a string into an array of substrings based on the specified delimiter.
- Arguments
text : string implicit
delim : string implicit
- split_by_chars(text: string implicit; delim: string implicit) : array<string>()
Splits the input string into an array of substrings based on the specified delimiter characters.
- Arguments
text : string implicit
delim : string implicit
- join(it: auto; separator: string implicit) : auto()
Joins the elements of an iterable into a single string, separated by the specified separator.
- Arguments
it : auto
separator : string implicit
- join(it: iterator<auto(TT)>; separator: string implicit) : auto()
Joins the elements of an iterable into a single string, separated by the specified separator.
- Arguments
it : iterator<auto(TT)>
separator : string implicit
- join(iterable: array<auto(TT)>; separator: string; blk: block<(var writer:StringBuilderWriter;elem:TT):void>) : string()
Joins the elements of an array into a single string, separated by the specified separator, using a custom block to convert each element to a string. :Arguments: * iterable : array<auto(TT)>
separator : string
blk : block<(writer: StringBuilderWriter ;elem:TT):void>
- join(iterable: iterator<auto(TT)>; separator: string; blk: block<(var writer:StringBuilderWriter;elem:TT):void>) : string()
Joins the elements of an iterable into a single string, separated by the specified separator, using a custom block to convert each element to a string.
- Arguments
iterable : iterator<auto(TT)>
separator : string
blk : block<(writer: StringBuilderWriter ;elem:TT):void>
- join(iterable: auto(TT)[]; separator: string; blk: block<(var writer:StringBuilderWriter;elem:TT):void>) : string()
Joins the elements of an array into a single string, separated by the specified separator, using a custom block to convert each element to a string.
- Arguments
iterable : auto(TT)[-1]
separator : string
blk : block<(writer: StringBuilderWriter ;elem:TT):void>
- split(text: string implicit; delim: string implicit; blk: block<(arg:array<string>#):auto>) : auto()
Splits a string into substrings based on the specified delimiter characters, invoking a custom block for each substring.
- Arguments
text : string implicit
delim : string implicit
blk : block<(arg:array<string>#):auto>
- split_by_chars(text: string implicit; delim: string implicit; blk: block<(arg:array<string>#):auto>) : auto()
Splits a string into substrings based on the specified delimiter characters, invoking a custom block for each substring.
- Arguments
text : string implicit
delim : string implicit
blk : block<(arg:array<string>#):auto>
15.2. Formatting
- wide(text: string implicit; width: int) : string()
Pads the given string to the specified width by appending spaces if necessary.
- Arguments
text : string implicit
width : int
15.3. Queries and comparisons
- is_character_at(foo: array<uint8>; idx: int; ch: int) : auto()
Returns whether the character at the specified index in the byte array matches the given character code.
- Arguments
foo : array<uint8> implicit
idx : int
ch : int
- eq(a: string implicit; b: das_string) : auto()
Compares a string with a das_string for equality.
- Arguments
a : string implicit
b : das_string
- eq(b: das_string; a: string implicit) : auto()
Compares a das_string with a string for equality.
- Arguments
b : das_string
a : string implicit
15.4. Replace
- replace_multiple(source: string; replaces: array<tuple<text:string;replacement:string>>) : string()
Replaces multiple substrings in the source string according to the provided list of replacements.
- Arguments
source : string
replaces : array<tuple<text:string;replacement:string>>
15.5. Levenshtein distance
- levenshtein_distance(s: string implicit; t: string implicit) : int()
Returns the Levenshtein distance between two strings.
- Arguments
s : string implicit
t : string implicit
- levenshtein_distance_fast(s: string implicit; t: string implicit) : int()
Returns the Levenshtein distance between two strings, which is a measure of the difference between them.
- Arguments
s : string implicit
t : string implicit