//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);
}
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.
Labels:
Actionscript,
AS2,
php
Subscribe to:
Post Comments (Atom)
4 comments:
What about blank string " " ? or block string "abcd" become "bcd" ?
Better use while and more tests
ralph lauren outlet
true 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
michael 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
20180623xiaoke
christian louboutin
oakley sunglasses wholesale
kd 10 elite
ray ban sunglasses outlet
pandora charms
true religion jeans sale
ralph lauren outlet
canada goose jackets
ugg boots on sale
chloe sunglassess
Post a Comment