Function kiwix::split¶
Defined in File tools.h
Function Documentation¶
-
std::vector<std::string>
kiwix
::
split
(const std::string &str, const std::string &delims, bool dropEmpty = true, bool keepDelim = false)¶ Split a string
This function is provided as a small helper. It is probably better to use native tools.
Assuming text = “foo:;bar;baz,oups;”
split(text, “:;”, true, true) => [“foo”, “:”, “;”, “bar”, “;”, “baz,oups”, “;”] split(text, “:;”, true, false) => [“foo”, “bar”, “baz,oups”] (default) split(text, “:;”, false, true) => [“foo”, “:”, “”, “;”, “bar”, “;”, “baz,oups”, “;”, “”] split(text, “:;”, false, false) => [“foo”, “”, “bar”, “baz,oups”, “”]
- Parameters
str – The string to split.
delims – A string of potential delimiters. Each charater in the string can be a individual delimiters.
dropEmpty – true if empty part must be dropped from the result.
keepDelim – true if delimiter must be included from the result.
- Returns
a list of part (potentially containing delimiters)