Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Replacing Double Curly Braces with javascript
  2. String.prototype.replaceWith = function(f, t) {
  3.     var regExp = new RegExp("[" + f + "]", "g");
  4.     return this.replace(regExp, t);
  5. };
  6.        
  7. '{{Hello}}'.replaceWith('{{','<<').replaceWith('}}','>>');
  8.        
  9. "<<<<Hello>>>>"
  10.        
  11. "<<Hello>>"
  12.        
  13. "[" + f + "]"
  14.        
  15. f
  16.        
  17. String.prototype.replaceWith = function(f, t) {
  18.     var regExp = new RegExp(f, "g");
  19.     return this.replace(regExp, t);
  20. };
  21.        
  22. "{{hello}}".replace("}}",">>").replace("{{","<<")
  23.        
  24. "<<hello>>"