@verb #555:"decode" this none this rxdo #60 @program #555:"decode" this none this "Convert a string like '* how* (this|candice)* work*' into:" "{{' how', ' this', ' work'}, {' how', ' candice', ' work'}}" tokens = {} {string} = args tokens = $su:tokenise(string, {"*", "(", "|", ")"}) "{'*', ' how', '*', ' ', '(', 'this', '|', 'candice', ')', '*', ' work', '*'}" templates = {{}} start = 1 cache = 0 for token in (tokens) if (token == "(") if (cache) return E_INVIND endif cache = templates elseif (token == "|") if (!cache) return E_INVIND endif start = length(templates) + 1 templates = {@templates, @cache} elseif (token == ")") if (!cache) return E_INVIND endif start = 1 cache = 0 else for x in [start..length(templates)] templates[x] = {@templates[x], token} endfor endif endfor "{{'*', ' how', '*', ' ', 'this', '*', ' work', '*'}, {'*', ' how', '*', ' ', 'candice', '*', ' work', '*'}}" outputs = {} for template in (templates) output = {} prev_word = "*" for word in (template) if (word != "*") if (prev_word == "*") output = {@output, word} else output[$] = output[$] + word endif endif prev_word = word $command_utils:suspend_if_needed() endfor if (output && output[1] && output[1][1] == "!" && output[1] != "!") output[1] = output[1][2..$] output = {"!", @output} endif outputs = {@outputs, output} endfor return outputs "Last modified by Dax (#789) on Wed Jan 16 22:14:26 2002 MST." .