parse file and put data in array?

Hi I am trying to read data from a file And I want to parse through the data and put it in an array.
The data looks like:
#Coordinates#_*1*2*0_*1*3*1_*2*4*1_*1*5*2 etc...
For each _ there is a new set of coordinates for an object, _*1*2*0 means that object 1 should have xcoordinate 2 and y coordinate 0, the next set is also for obect 1 but then it has moved to coordinate x=3 and y=1 and so on.

I have used the follwoing code to read the data from file:
var myLoader:URLLoader = new URLLoader()
myLoader.dataFormat = URLLoaderDataFormat.TEXT

myLoader.load(new URLRequest("data.txt"))
myLoader.addEventListener(Event.COMPLETE, onDataLoad)
myLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError)
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError)
myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus)

function onDataLoad(evt:Event){

comments_txt.text = evt.target.data; //I put the data in a textfield on the stage just to see that
//I have read the data, its here I assume that I should do anything smart

}

Everything works fine above but I don't know how to parse the data to an dataclass or an array, please help me.
I cannot change the format of the textfile, If I could then I would use VARIABLES instead of TEXT as URLLoaderDataFormat
Basically there are two main ways to store stuff in a file, human readable and machine readable. Your formatting seems a bit difficult for human readable, so I would suggest going with XML if you want it readable. If you are having it work with an editor, I would save it in a binary format. Here's a very relevant link:

Binary Maps and Data in AS3

It sounds like you are committed to your setup for right now though, so what you are going to need to do is parse the string using some String functions. You could use RegExp too, but it is more difficult to understand and you might want to start with the basics. The public methods of String can be found here. You could loop through getting charAt() whatever index you are on, and then use an "if" to determine what to do. I would set a flag for when you hit a _ so that you create a new object. Then set a flag when you hit a number and concatenate each number in string form to a temp string and then cast to int.

This isn't the most efficient way to do this, but maybe the easiest to understand if you are set on that file format.
thx, I will look into the sting functions.
The data I will read from the file is set by another guy, maybe I can convince him to chnge the format but he isn't using flash, its some old programing language.
I though that it would be asier for me to read the data then it was for him to change it so as for now the data won't change.
I am quite familiar with perl in which I use RegExp often so it won't be a problem. Is it easy to use in flash too?

In perl I should create an array like @myarray using split and then split it again and set each attribut in a dataklass.

But how do I do it in flash?
Which variable type should I use to store the input data and how can I set the data in an array of dataclasses for example?
Regex's are pretty easy to use in Flash (though not quite as great a perl). There's no splitting by regex though, so you'd have to do something like (ripped from the AS3 reference, but untested):

Code:
myRegExp:RegExp = /_\*(\d*)\*(\d*)\*(\d*)/ig

var result:Object = myRegExp.exec(str);
while (result != null) {
  var id:Number = parseInt(result[1],10);
  var x:Number = parseInt(result[2],10);
  var y:Number = parseInt(result[3],10);
  //Do what ever you want with this
  result = myRegExp.exec(str);
}

You might need some adaptations for floats.

EDIT: Off by 1 error
ok, thx I will try it! thx so much for the example also!
One more question, is it ok to temporarily store the "unparsed" message, ie the data from the file in a string or do you read directly from the filebuffer? didn't understand how to temporarily store it and was affraid to use string or something since the data could be very big, there can be 1000 of coordinates.

Original thread: https://box2d.org/forum/viewtopic.php?t=480