Module SeparatedEscape
A module for making CSV-like separated strings, with a custom separator and escape character.
When the separator or escape character is found in a string to be concatenated, it is escaped
with the escape character. For example, if the separator is , and the escape character is \,
then adding joining foo,bar with baz\\qux will yield foo\\,bar,baz\\\\qux.
Example usage:
import SeparatedEscape<Separator::comma/0, defaultEscapeMap> as CSV
// Selects "foo\\,bar,baz\\\\qux"
select CSV::EscapeBackslash::join("foo,bar", "baz\\qux")
// Selects [0, "foo,bar"] and [1, "baz\\qux"]
from int i, string s
where s = CSV::EscapeBackslash::split("foo\\bar,baz\\\\qux", i)
select i, s
string getItem(int i) { ... }
select CSV::concatIndexed<getItem/1>::join()
Import path
import qtil.strings.EscapePredicates
| escapeItem | Escape a string using the escape map, using backslash as the escape character. |
| escapeItem | Escape a string using the escape map, using a custom escape character. |
| split | Split a string into its unescaped component parts, by the separator character, using backslash as the escape character. |
| split | Split and unescape the nth item in the string, starting at zero, separated by the separator character. |
| split | Split and unescape the nth item in the string, starting at zero, separated by the separator character, escaped by a custom escape character. |
| splitWithEscaper | Split a string into its unescaped component parts, by the separator character, using a custom escape character. |
| unescapeItem | Unescape a string using the escape map, using backslash as the escape character. |
| unescapeItem | Unescape a string using the escape map, using backslash as the escape character. |
Modules
| Concat | A module that can concatenate all of the results of a predicate, unordered, using the specified separator and escaping each item as necessary. |
| EscapeBackslash | A module containing a set of functions |
| EscapedWith | A module containing a set of functions |