[Turn off line numbering]1: arg line, @opts; 2: var x, output, tmp; 3: 4: if (!line) 5: return []; 6: 7: // explodes an english list ("foo, bar and zoo"). 8: line = line.explode(","); 9: output = []; 10: for x in (line) { 11: x = .trim(x); 12: if ((| x.subrange(1, 4) |) == "and ") 13: output += [.trim(x.subrange(4))]; 14: else 15: output += [x]; 16: } 17: 18: // check the last element, if they didn't specify 'noand 19: if (!('noand in opts)) { 20: line = output[output.length()].explode(); 21: tmp = ""; 22: for x in [1 .. line.length()] { 23: if (line[x] == "and") { 24: output = output.delete(output.length()); 25: if (tmp) 26: output += [tmp]; 27: tmp = line.subrange(x + 1).join(); 28: if (tmp) 29: output += [tmp]; 30: 31: // only bother with the first "and" 32: break; 33: } 34: tmp = tmp + (tmp ? " " : "") + line[x]; 35: } 36: } 37: return output;
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit