//USAGE:
trace(trim(";A test;;", ";")); //outputs: "A test"
function trim(str:String, char:String):String{
if(char==undefined){char=" ";}
code=char.charCodeAt(0)
for(var i = 0; str.charCodeAt(i) ==code; i++);
for(var j = str.length-1; str.charCodeAt(j) ==code; j--);
return str.substring(i, j+1);
}
Useful scripts, utilities and classes for developers of HTML, PHP, Javascript, Actionscript, mySQL, CSS, etc. This blog will fill the occasional gaps in information I stumble across in my daily developing. If there's something I feel is missing from the vast pool of stuff already out there, I'll post it here. I'm a nice guy. You'd like me.
11 November 2009
AS2: PHP style trim for Actionscript 2 - with 'any' character support
Theres a few of these functions around but none (that I could find) will allow you to trim non whitespace characters so I pulled this one together which lets you trim any character you want.
What about blank string " " ? or block string "abcd" become "bcd" ?
ReplyDeleteBetter use while and more tests
ralph lauren outlet
ReplyDeletetrue religion outlet
jordan shoes
coach outlet
ugg outlet
nike air force 1
canada goose sale
gucci handbags
nike shoes
kevin durant shoes
20161228caiyan
coach outlet
ReplyDeletemichael kors outlet
nfl jerseys wholesale
christian louboutin outlet
coach outlet online
canada goose outlet
canada goose outlet store
canada goose outlet
christian louboutin sale
pandora outlet
shenyuhang20180608
Interesting thoughhts
ReplyDelete