]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/jslib.js
Merge.
[irc/quakenet/qwebirc.git] / js / jslib.js
index ba9acf0e3478d188f1b1f562334dee79e4708552..994bf419901aaf80947e1b49f54103b4b4b5f6c0 100644 (file)
@@ -17,6 +17,7 @@ qwebirc.util.dictCopy = function(d) {
 
 /* how horribly inefficient */
 String.prototype.replaceAll = function(f, t) {
+  //return new RegExp("/" + RegExp.escape(f) + "/g").replace(f, RegExp.escape(t));
   var i = this.indexOf(f);
   var c = this;
  
@@ -117,15 +118,7 @@ qwebirc.util.pad = function(x) {
 }
 
 RegExp.escape = function(text) {
-  if(!arguments.callee.sRE) {
-    var specials = [
-      '/', '.', '*', '+', '?', '|',
-      '(', ')', '[', ']', '{', '}', '\\'
-    ];
-    arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
-  }
-  
-  return text.replace(arguments.callee.sRE, '\\$1');
+  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
 }
 
 qwebirc.ui.insertAt = function(position, parent, element) {