
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.50 KB | hits: 16 | expires: Never
Replacing Double Curly Braces with javascript
String.prototype.replaceWith = function(f, t) {
var regExp = new RegExp("[" + f + "]", "g");
return this.replace(regExp, t);
};
'{{Hello}}'.replaceWith('{{','<<').replaceWith('}}','>>');
"<<<<Hello>>>>"
"<<Hello>>"
"[" + f + "]"
f
String.prototype.replaceWith = function(f, t) {
var regExp = new RegExp(f, "g");
return this.replace(regExp, t);
};
"{{hello}}".replace("}}",">>").replace("{{","<<")
"<<hello>>"