Skip to content

Instantly share code, notes, and snippets.

@rixtox
Last active August 29, 2015 14:00
Show Gist options
  • Save rixtox/11519348 to your computer and use it in GitHub Desktop.
Save rixtox/11519348 to your computer and use it in GitHub Desktop.
var result = ~ function(str) {
// Define a DSL
var r = function(target, replace) {
str = str.replace(new RegExp(target, 'gi'), replace || target);
};
// Use the DSL
r('JavaScript');
r('gogle', 'Google');
// Or even much cooler
var list = [
'jQuery',
'Mac OS',
['adress', 'address']
];
list.each(function(item) {
r.apply(this, [].concat(item));
});
return str;
} ($('.something').text());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment