Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(var i = 0; i < agrs.length; i++){
- reg = new RegExp('{'+i+'}', 'gi');
- key = key.replace(reg,agrs[i])
- new RegExp('\{'+i+'\}', 'gi');
- s='the song says {0} little {1} little {2} little-endians';
- args=['zero','one','two'];
- new_string = s.replace(/{([0-9]+)}/g, function(wholematch,firstmatch)
- {return args[(+firstmatch)]; }
- );
- the song says zero little one little two little-endians
- s='the song says {0} little {1} little {2} little-endians,n'+
- ' {3} little {4} little {5} little-endians';
- args=['zero','one','two'];
- new_string = s.replace(/{([0-9]+)}/g, function(wholematch,firstmatch)
- {var i = +firstmatch; return i < args.length ? args[i] : wholematch;}
- );
- the song says zero little one little two little-endians,
- {3} little {4} little {5} little-endians
- reg = new RegExp('{'+i+'}', 'gi');
Add Comment
Please, Sign In to add comment