SHARE
TWEET

Untitled

a guest Oct 18th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String.format = function() {
  2.         if( arguments.length == 0 )
  3.             return null;
  4.         var str = arguments[0];
  5.         for(var i=1;i<arguments.length;i++) {
  6.             var re = new RegExp('\\{' + (i-1) + '\\}','gm');
  7.             str = str.replace(re, arguments[i]);
  8.         }
  9.         return str;
  10.     };
  11.  
  12.   // String.format('今天星期{0}', '一')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top