/*
 * $Id: StrUtils.js 30 2009-09-15 20:35:45Z terence $
 *
 * Copyright (c) 2008 Terence Honles (terence.honles.com)
 * see: terence.honles.com/js/ for usage and src
 */
String.prototype.formatPattern=/({?){([^}]+)}(}?)/g;String.prototype.format=function(){var f=arguments;if(f.length==1){var d=f[0];if(typeof d=="object"&&d!=null&&d.constructor!=String){f=d}}var g=this.split(this.formatPattern);var a=new Array();for(var c=0,e=g.length;c<e;c+=4){a.push(g[c]);if(e>c+3){var b=g[c+1];var j=g[c+2];var h=g[c+3];if(b=="{"&&h=="}"){a.push(b,j,h)}else{j=j.strip();if(!(j in f)){throw new Error("field {"+j+"} was not found")}a.push(b,f[j],h)}}}return a.join("")};String.prototype.strip=function(a){if(!a){a="\\s+"}else{if(a.source){a=a.source}}return this.replace(new RegExp("^"+a+"|"+a+"$"),"")};String.prototype.lstrip=function(a){if(!a){a="\\s+"}else{if(a.source){a=a.source}}return this.replace(new RegExp("^"+a),"")};String.prototype.rstrip=function(a){if(!a){a="\\s+"}else{if(a.source){a=a.source}}return this.replace(new RegExp(a+"$"),"")};