Here's a quick function to split string to array by begin and end key strings:
ActionScript Code:
var someText:String = "Useless text i dont need\n[start]this is the text i need to find and store[finish]\nuseless text i dont need\n[start]store and find this too[finish]\nuseless text...";
var array:Array = splitByKeys(someText, "[start]", "[finish]");
trace(array[0]); // this is the text i need to find and store
trace(array[1]); // store and find this too
function splitByKeys(string:String, begin:String, end:String):Array
{
if(begin.length + end.length == 0) return string.split("");
var i:int = 0;
var j:int = 0;
var round:int = 0;
var array:Array = [];
while(true)
{
i = string.indexOf(begin, (round++ != 0 ? j + end.length : i));
j = string.indexOf(end, i + begin.length);
array.push(string.substring(i + begin.length, j));
if(i == -1 || j == -1) break;
}
array.pop();
if(array.length == 0) throw new Error("parameter \"string\" doesn't contain both keys!");
return array;
}
Will throw and error if string doesn't contain begin and end key strings.