import extensions; import extensions'routines; import system'collections; import system'routines; import system'text; extension op : String { tokenize(separator,escape) { auto buffer := new TextBuilder(); auto list := new ArrayList(); bool escaping := false; self.forEach::(ch) { if (escaping) { buffer.write(ch); escaping := false } else if (ch == escape) { escaping := true } else if (ch == separator) { list.append(buffer.Value); buffer.clear() } else { buffer.write(ch) } }; ^ list } } const string Testcase = "one^|uno||three^^^^|four^^^|^cuatro|"; public Program() { Testcase.tokenize("|", "^").forEach(PrintingLn) }