From: Scott H. <sco...@us...> - 2005-06-29 08:08:08
|
Update of /cvsroot/actionstep/actionstep/src/org/actionstep In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5922/src/org/actionstep Modified Files: ASUtils.as Log Message: added a trimString method Index: ASUtils.as =================================================================== RCS file: /cvsroot/actionstep/actionstep/src/org/actionstep/ASUtils.as,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ASUtils.as 29 Jun 2005 05:04:37 -0000 1.11 --- ASUtils.as 29 Jun 2005 08:07:59 -0000 1.12 *************** *** 132,134 **** --- 132,151 ---- return result; } + + /** + * Removes whitespace from the beginning and end of a string. + */ + public static function trimString(str:String):String + { + var end = str.length; + var start = 0; + var white = new Object(); + white["_"+" ".charCodeAt(0)] = 1; + white["_"+"\n".charCodeAt(0)] = 1; + white["_"+"\r".charCodeAt(0)] = 1; + white["_"+"\t".charCodeAt(0)] = 1; + while(white["_"+str.charCodeAt(--end)]); + while(white["_"+str.charCodeAt(start++)]); + return str.slice(start-1,end+1); + } } \ No newline at end of file |