Method code for $string.explode_quoted()

[Turn on line numbering]
arg str;
var out, result, x, qstr;

out = [];

// HACK: we need to make this a native--its horribly inefficient
qstr = "#$#QUOTE-" + time() + "#$#";
str = strsub(str, "\\"", qstr);
while (str) {
    result = match_pattern(str, "*\"*\"*");
    if (result) {
        out += result[1].explode() + [result[2].trim()];
        str = result[3];
    } else {
        out += str.explode();
        str = "";
    }
}
for x in [1 .. listlen(out)]
    out = replace(out, x, strsub(out[x], qstr, "\""));
return out;

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon