Archive for August, 2010

get charectors between two charectors in string

String.prototype.between = function(i1, i2)
{
 var iA:String = this.indexOf(i1) + i1.length;
 if (i1 != i2 && this.indexOf(i1, iA) == -1)
 var iB:String = this.indexOf(i2, iA);
 else
 return this.substring(iA).between(i1, i2);
 return this.substring(iA, iB);
};

remove an element from an array Prototype


Array.prototype.remove = function(i) {
 this.splice(i, 1);
};

myArray = new Array("0", "1", "2", "3", "4", "5", "6");

myArray.remove(5, 1);
trace(myArray)

myArray.remove(2, 1);
trace(myArray)

myArray.remove(2, 1);
trace(myArray)
/*
0,1,2,3,4,6
0,1,3,4,6
0,1,4,6
*/