[Turn off line numbering]1: arg str, left, right; 2: var pattern, parsed, matched, match_num, match_result; 3: 4: // parse str looking for anything surrounded by left and right 5: // ;$string.explode_delimited("foo<bar>baz", "<", ">") 6: // => [["foo", 1, "baz"], ["bar"]] 7: pattern = "*" + left + "*" + right + "*"; 8: parsed = []; 9: matched = []; 10: match_num = 0; 11: anticipate_assignment(); 12: while (str) { 13: match_result = match_pattern(str, pattern); 14: if (match_result) { 15: match_num++; 16: parsed += [match_result[1], match_num]; 17: matched += [match_result[2]]; 18: str = match_result[3]; 19: } else { 20: parsed += [str]; 21: str = ""; 22: } 23: } 24: return [parsed, matched];
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit