달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
String.prototype.format = function ()
{
    // The string containing the format items (e.g. "{0}")
    // will and always has to be the first argument.
    var theString = this;
 
    // start with the second argument (i = 1)
    for (var i = 0; i < arguments.length; i++)
    {
        // "gm" = RegEx options for Global search (more than one instance)
        // and for Multiline search
        var regEx = new RegExp("\\{" + (i) + "\\}", "gm");
        theString = theString.replace(regEx, arguments[i]);
    }
 
    return theString;
};


Posted by 은하비류연
|