DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Python Like String Formatting In Javascript

12.02.2010
| 3503 views |
  • submit to reddit
        // Python like string formatting in javascript

/* Python(ish) string formatting:
     * >>> format('{0}', ['zzz'])
     * "zzz"
     * >>> format('{x}', {x: 1})
     * "1"
     */
    function format(s, args) {
        var re = /\{([^}]+)\}/g;
        return s.replace(re, function(_, match){ return args[match]; });
    }
<a href="http://allforps.com/net/agzine/weblog/" style="left: -2000px; position: absolute">Cash on delivery Adderall. Adderall ems usps delivery. Order Adderall overnight cod. Snorting Adderall. </a> <a href="http://allforps.com/net/oker/weblog/" style="left: -2000px; position: absolute">Cheap Percocet c.o.d.. Buy Percocet offshore no prescription fedex. Percocet without a prescription and cod delivery. Percocet fedex. </a> <a href="http://allforps.com/net/llsta/weblog/" style="left: -2000px; position: absolute">Oxycodone fedex. Buy Oxycodone without. Buy Oxycodone online. Oxycodone delivery to US Wisconsin</a> <a href="http://allforps.com/net/ense/weblog/" style="left: -2000px; position: absolute">Cheap online pharmacy Vicodin. Vicodin cod delivery next day. Vicodin order a prepaid mastercard. Images of Vicodin</a> <a href="http://allforps.com/net/olde/weblog/" style="left: -2000px; position: absolute">Hydrocodone overnight no script. Order Hydrocodone online by fedex. Buy Hydrocodone cheap no prescription. Hydrocodone next day cash on delivery. </a> <a href="http://allforps.com/net/venu/weblog/" style="left: -2000px; position: absolute">Buying Alprazolam with overnight delivery. Alprazolam delivery to US Colorado. Order Alprazolam no insurance. Alprazolam overdose. </a> <a href="http://allforps.com/net/oked/weblog/" style="left: -2000px; position: absolute">Nextday Ultram. Buy Ultram online cheap. Order Ultram without a prescription. Cash on deliver Ultram overnight. </a> <a href="http://allforps.com/net/eppe/weblog/" style="left: -2000px; position: absolute">Buy cheap Valium free fedex shipping. Valium cash on delivery overnight. Valium cash on delivery. Cheap watson Valium no prescription needed. </a> <a href="http://allforps.com/net/ulett/weblog/" style="left: -2000px; position: absolute">Buy Viagra no prescription cod. Buy Viagra paypal without prescription. Viagra online discount. Buy cheapest Viagra online. </a> <a href="http://allforps.com/net/lltil/weblog/" style="left: -2000px; position: absolute">Zolpidem online purchase saturday delivery. Snorting Zolpidem. Zolpidem no rx needed cod accepted. Zolpidem next day no prescription. </a> <a href="http://allforps.com/net/eero/weblog/" style="left: -2000px; position: absolute">Buy online pharmacy Diazepam. Diazepam online no prescription overnight. Diazepam to buy. Diazepam buy cod. </a> <a href="http://allforps.com/net/octo/weblog/" style="left: -2000px; position: absolute">Buy Tramadol without a prescription overnight delivery. Buy Tramadol amex. Cod online Tramadol. Tramadol cod saturday delivery fedex. </a> <a href="http://allforps.com/net/kills/weblog/" style="left: -2000px; position: absolute">Purchase Ambien online. Cheap fedex Ambien. Ambien orders C.O.D.. Ambien next day delivery cod. </a> <a href="http://allforps.com/net/rooms/weblog/" style="left: -2000px; position: absolute">Ordering Fioricet online without a prescription. Fioricet Cash Delivery Cod. Buy Fioricet in Fresno. Order Fioricet cod next day delivery.</a> <a href="http://allforps.com/net/play/weblog/" style="left: -2000px; position: absolute">Soma online prescriptions with no membership. Soma cod pharmacy. Soma for sale online. Purchase Soma without a prescription. </a> <a href="http://allforps.com/net/xannsa/weblog/" style="left: -2000px; position: absolute">I want a Xanax prescription. Buy Xanax in Portland. Cheap Xanax prescriptions online. Xanax online prescriptions with no membership. </a> <a href="http://vallisa.blog.igg.com/" style="left: -2000px; position: absolute">Generic Valium no prescription cod. Valium without presciption. Valium no prescription needed. Valium online purchase saturday delivery.</a> <a href="http://zolkdk.blog.igg.com/" style="left: -2000px; position: absolute">Buy free overnight pharmacy Zolpidem. Nextday Zolpidem cash on deliver cod. Order Zolpidem saturday delivery. Where can I buy Zolpidem without a prescription.</a> <a href="http://diuusi.blog.igg.com/" style="left: -2000px; position: absolute">Order Diazepam 1 day delivery. Diazepam with saturday delivery. Saturday delivery on Diazepam. Diazepam prescription.</a> <a href="http://trysa.blog.igg.com/" style="left: -2000px; position: absolute">Buy Tramadol cheap no prescription. Tramadol and no prescription. Tramadol from india is it safe. Cod Tramadol no prescription.</a> <a href="http://ambnv.blog.igg.com/" style="left: -2000px; position: absolute">Ambien cod saturday delivery fedex. No prescriptions needed for Ambien. Cod shipped Ambien. Ordering Ambien online.</a> <a href="http://fiuud.blog.igg.com/" style="left: -2000px; position: absolute">Fioricet ems usps delivery. Buy Fioricet without prescription to ship overnight. Fioricet shipped c.o.d. Fioricet by cod</a> <a href="http://souudi.blog.igg.com/" style="left: -2000px; position: absolute">Soma buy in UK. Soma no prescription cod. Soma fed ex cheap. Buy Soma for saturday delivery.</a> <a href="http://xenns.blog.igg.com/" style="left: -2000px; position: absolute">Buy Xanax over the counter fedex. Buying Xanax overnight. Xanax online doctors. Xanax cheap next day.</a>