[Turn off line numbering]1: arg string, regexp; 2: var result, location, left, begin_match, end_match; 3: 4: result = []; 5: left = string; 6: while (left) { 7: if ((location = match_regexp(left, regexp))) { 8: [begin_match, end_match] = location[1]; 9: result += [begin_match == 1 ? "" : left.subrange(1, begin_match - 1)]; 10: result += [left.subrange(begin_match, end_match)]; 11: left = left.subrange(begin_match + end_match); 12: } else { 13: result += [left]; 14: left = ""; 15: } 16: } 17: if (!(result.length() % 2)) 18: result += [""]; 19: return result;
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit