Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function STRING(str, hash) {
- var new_str = str;
- for (var key in hash) {
- var regex = new RegExp(':' + key.toString(), "g");
- new_str = new_str.replace(regex, hash[key]);
- }
- return new_str;
- }
- var txt = STRING('testing this :first (:first) making :script', {
- first: 'FIRST',
- script: 'SCRIPT'
- });
- document.write(txt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement