Function memflow::plugins::args::split_str_args
source · pub fn split_str_args(inp: &str, split_char: char) -> impl Iterator<Item = &str>
Expand description
Split a string into a list of separate parts based on ‘:’ delimiter
This is a more advanced version of splitting that allows to do some basic escaping with quotation marks.
Examples
use memflow::plugins::args::split_str_args;
let v: Vec<_> = split_str_args("a:b:c", ':').collect();
assert_eq!(v, ["a", "b", "c"]);
let v: Vec<_> = split_str_args("a::c", ':').collect();
assert_eq!(v, ["a", "", "c"]);
let v: Vec<_> = split_str_args("a:\"hello\":c", ':').collect();
assert_eq!(v, ["a", "hello", "c"]);
let v: Vec<_> = split_str_args("a:\"hel:lo\":c", ':').collect();
assert_eq!(v, ["a", "hel:lo", "c"]);
let v: Vec<_> = split_str_args("a:\"hel:lo:c", ':').collect();
assert_eq!(v, ["a", "\"hel:lo:c"]);
let v: Vec<_> = split_str_args("a:'hel\":lo\"':c", ':').collect();
assert_eq!(v, ["a", "hel\":lo\"", "c"]);
let v: Vec<_> = split_str_args("a:hel\":lo\":c", ':').collect();
assert_eq!(v, ["a", "hel\":lo\"", "c"]);