// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// file: string.js
// desc: string prototypes
// auth: Héctor J. Rivas torjo2k@hotmail.com
// updt: Wed Feb 16 11:16:50 UTC-0400 2005
//		 Wed Apr 20 16:30:06 UTC-0400 2005
// 		 Tue Oct 17 16:25:05 CDT 2006 The Code Project version
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// trimming with array ops
String.prototype.trim = function() { return this.split(/\s/).join(' '); }

// string replicator 
String.prototype.times = function(n) { s = ''; for (i = 0; i < n; i++) s += this; return s; }

// zero padding and trailing
String.prototype.zp = function(n) { return '0'.times(n - this.length) + this; }
String.prototype.zt = function(n) { return this + '0'.times(n - this.length); }

// string reverse
String.prototype.reverse = function() { return this.split('').reverse().join(''); }

// clear format from a string representation of a number
String.prototype.clean = function() { return parseFloat(this.replace(/[^0-9|.|-]/g, '')); }
