1 var comb = exports; 2 3 4 comb.isRexExp = function(obj){ 5 var undef; 6 return obj !== undef && obj != null && (obj instanceof RegExp); 7 }; 8 9 /** 10 * @namespace Regeular expression utilities 11 * 12 */ 13 comb.regexp = { 14 /** 15 * Escapes a string 16 * 17 * @param {String} str the string to escape 18 * @param {String} [except] characters to ignore 19 * 20 * @returns {String} the escaped string 21 */ 22 escapeString : function(/*String*/str, /*String?*/except) { 23 return str.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, function(ch) { 24 if (except && except.indexOf(ch) != -1) { 25 return ch; 26 } 27 return "\\" + ch; 28 }); // String 29 } 30 };