3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

Escape snippet

This commit is contained in:
Sam Nicholls 2012-12-29 18:42:32 +00:00
parent e7addd9ff4
commit 863e862731

View File

@ -263,3 +263,8 @@ Number.prototype.numberFormat = function(dec_places){
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, sep); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, sep);
return parts.join(dec_point); return parts.join(dec_point);
} }
// http://simonwillison.net/2006/Jan/20/escape/#p-6
String.prototype.escape = function() {
return this.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}