Revision: 7803
Updated Code
at December 9, 2009 08:53 by wizard04
Updated Code
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.ltrim = function(){ return this.replace(/^\s+/, ""); };
String.prototype.rtrim = function(){ return this.replace(/\s+$/, ""); };
String.prototype.padLeft = function(str, len, padChar)
{
if(!padChar) padChar = " ";
while(str.length < len){ str = padChar+str; }
return str;
}
String.prototype.padRight = function(str, len, padChar)
{
if(!padChar) padChar = " ";
while(str.length < len){ str = str+padChar; }
return str;
}
//opposite of String.slice; removes a section of a string and returns what's left
String.prototype.prune = function(start, end)
{
var result = this.slice(0, start);
if(!isNaN(end)) result += this.slice(end);
return result;
}
String.prototype.rot13 = function()
{
var a=97, m=109, n=110, z=122, A=65, M=77, N=78, Z=90;
var len = this.length, c, str = "";
for(var i=0; i<len; i++)
{
c = this.charCodeAt(i);
if((a <= c && c <= m) || (A <= c && c <= M)) str += String.fromCharCode(c+13);
else if((n <= c && c <= z) || (N <= c && c <= Z)) str += String.fromCharCode(c-13);
else str += this[i];
}
return str;
}
Revision: 7802
Updated Code
at December 8, 2009 12:42 by wizard04
Updated Code
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.ltrim = function(){ return this.replace(/^\s+/, ""); };
String.prototype.rtrim = function(){ return this.replace(/\s+$/, ""); };
String.prototype.padLeft = function(str, len, padding)
{
if(!padding) padding = " ";
while(str.length < len){ str = padding+str; }
return str;
}
String.prototype.padRight = function(str, len, padding)
{
if(!padding) padding = " ";
while(str.length < len){ str = str+padding; }
return str;
}
//opposite of String.slice; removes a section of a string and returns what's left
String.prototype.prune = function(start, end)
{
var result = this.slice(0, start);
if(!isNaN(end)) result += this.slice(end);
return result;
}
String.prototype.rot13 = function()
{
var a=97, m=109, n=110, z=122, A=65, M=77, N=78, Z=90;
var len = this.length, c, str = "";
for(var i=0; i<len; i++)
{
c = this.charCodeAt(i);
if((a <= c && c <= m) || (A <= c && c <= M)) str += String.fromCharCode(c+13);
else if((n <= c && c <= z) || (N <= c && c <= Z)) str += String.fromCharCode(c-13);
else str += this[i];
}
return str;
}
Revision: 7801
Updated Code
at August 13, 2008 16:02 by wizard04
Updated Code
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.ltrim = function(){ return this.replace(/^\s+/, ""); };
String.prototype.rtrim = function(){ return this.replace(/\s+$/, ""); };
//opposite of String.slice; removes a section of a string and returns what's left
String.prototype.prune = function(start, end)
{
var result = this.slice(0, start);
if(!isNaN(end)) result += this.slice(end);
return result;
}
String.prototype.rot13 = function()
{
var a=97, m=109, n=110, z=122, A=65, M=77, N=78, Z=90;
var len = this.length, c, str = "";
for(var i=0; i<len; i++)
{
c = this.charCodeAt(i);
if((a <= c && c <= m) || (A <= c && c <= M)) str += String.fromCharCode(c+13);
else if((n <= c && c <= z) || (N <= c && c <= Z)) str += String.fromCharCode(c-13);
else str += this[i];
}
return str;
}
Revision: 7800
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 13, 2008 16:00 by wizard04
Initial Code
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.ltrim = function(){ return this.replace(/^\s+/, ""); };
String.prototype.rtrim = function(){ return this.replace(/\s+$/, ""); };
//opposite of slice; removes a section of a string and returns what's left
String.prototype.prune = function(start, end)
{
var result = this.slice(0, start);
if(!isNaN(end)) result += this.slice(end);
return result;
}
String.prototype.rot13 = function()
{
var a=97, m=109, n=110, z=122, A=65, M=77, N=78, Z=90;
var len = this.length, c, str = "";
for(var i=0; i<len; i++)
{
c = this.charCodeAt(i);
if((a <= c && c <= m) || (A <= c && c <= M)) str += String.fromCharCode(c+13);
else if((n <= c && c <= z) || (N <= c && c <= Z)) str += String.fromCharCode(c-13);
else str += this[i];
}
return str;
}
Initial URL
Initial Description
Initial Title
String functions
Initial Tags
javascript
Initial Language
JavaScript