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 const implicit; delim: string const implicit)

split returns array<string>

argument

argument type

text

string const implicit

delim

string const implicit

Split string given delimiter.

split_by_chars(text: string const implicit; delim: string const implicit)

split_by_chars returns array<string>

argument

argument type

text

string const implicit

delim

string const implicit

Split string given set of delimiters (string treated as characters).

join(it: auto const; separator: string const implicit)

join returns auto

argument

argument type

it

auto const

separator

string const implicit

Join mulitiple strings with delimiter.

join(iterable: array<auto(TT)> const; separator: string const; blk: block<(var writer:StringBuilderWriter;elem:TT const):void> const)

join returns string

argument

argument type

iterable

array<auto(TT)> const

separator

string const

blk

block<(writer: strings::StringBuilderWriter ;elem:TT const):void> const

Join mulitiple strings with delimiter.

join(iterable: iterator<auto(TT)> const; separator: string const; blk: block<(var writer:StringBuilderWriter;elem:TT const):void> const)

join returns string

argument

argument type

iterable

iterator<auto(TT)> const

separator

string const

blk

block<(writer: strings::StringBuilderWriter ;elem:TT const):void> const

Join mulitiple strings with delimiter.

join(iterable: auto(TT) const[]; separator: string const; blk: block<(var writer:StringBuilderWriter;elem:TT const):void> const)

join returns string

argument

argument type

iterable

auto(TT) const[-1]

separator

string const

blk

block<(writer: strings::StringBuilderWriter ;elem:TT const):void> const

Join mulitiple strings with delimiter.

split(text: string const implicit; delim: string const implicit; blk: block<(arg:array<string> const#):auto> const)

split returns auto

argument

argument type

text

string const implicit

delim

string const implicit

blk

block<(arg:array<string> const#):auto> const

Split string given delimiter.

split_by_chars(text: string const implicit; delim: string const implicit; blk: block<(arg:array<string> const#):auto> const)

split_by_chars returns auto

argument

argument type

text

string const implicit

delim

string const implicit

blk

block<(arg:array<string> const#):auto> const

Split string given set of delimiters (string treated as characters).

15.2. Formatting

wide(text: string const implicit; width: int const)

wide returns string

argument

argument type

text

string const implicit

width

int const

Pad string with ` ` character to make it certain width.

15.3. Queries and comparisons

is_character_at(foo: array<uint8> const implicit; idx: int const; ch: int const)

is_character_at returns auto

argument

argument type

foo

array<uint8> const implicit

idx

int const

ch

int const

Returns true if specific character is at specific string position.

eq(a: string const implicit; b: das_string const)

eq returns auto

argument

argument type

a

string const implicit

b

builtin::das_string const

Compares das_string and string. True if equal.

eq(b: das_string const; a: string const implicit)

eq returns auto

argument

argument type

b

builtin::das_string const

a

string const implicit

Compares das_string and string. True if equal.

15.4. Replace

replace_multiple(source: string const; replaces: array<tuple<text:string;replacement:string>> const)

replace_multiple returns string const

argument

argument type

source

string const

replaces

array<tuple<text:string;replacement:string>> const

Replace multiple substrings in string.

15.5. Levenshtein distance

levenshtein_distance(s: string const implicit; t: string const implicit)

levenshtein_distance returns int

argument

argument type

s

string const implicit

t

string const implicit

Returns Levenshtein distance between two strings.

levenshtein_distance_fast(s: string const implicit; t: string const implicit)

levenshtein_distance_fast returns int

argument

argument type

s

string const implicit

t

string const implicit

Returns Levenshtein distance between two strings, fast implementation.

15.6. Character traits

is_hex(ch: int const)

is_hex returns bool

argument

argument type

ch

int const

Returns true if character is hex digit.

is_tab_or_space(ch: int const)

is_tab_or_space returns bool

argument

argument type

ch

int const

Returns true if character is tab or space.