As this looks a lot like XML, why not coerce it into an XML object and then look for nodes within it?
--- In [email protected], "Claudia Barnal" <[EMAIL PROTECTED]> wrote: > > Hi Shaun, > > Thanks a lot for your help. But was tying to avoid using the loop, > given that it might slow down the process if there are a lot of items > matching the regexp. > > Claudia > > On Wed, Apr 23, 2008 at 8:46 PM, shaun <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > Hi Claudia, > > > > > > > > Claudia Barnal wrote: > > > Hi there, > > > > > > I have a string that needs to have some portions extracted through > > > regexp and add them to an array. > > > > > > the string is something like this: > > > > > > "<fruits><banana /><orange /></fruits> <vehicles><suv /><pickup > > > /><vehicles> <fruits><apple /><banana /></fruits>" > > > > > > So the regexp should return all that's between all <fruits> and > > > </fruits> in this case, it should be something like this: > > > "<banana /><orange /><apple /><banana />" > > > > > > then using > > > myArray = myString.split(myRegexp); > > > > > > I would get an array that looks like this > > > ["<banana /><orange />", "<apple /><banana />"] > > > > > > I've tried this regexp: "<fruits>.*?</fruits>" but it's not really > > > working, as it gives me whatever is outside the fruit nodes. > > > > > > Any pointers? > > > > > > > private function init():void{ > > > > var s:String = "<fruits><banana /><orange /></fruits>"+ > > > > "<vehicles><suv /><pickup/><vehicles> <fruits>"+ > > "<apple /><banana/></fruits>"; > > > > var r:RegExp = /<fruits>([\w\s><\\\/]*?)<\/fruits>/gi; > > var result:Array; > > > > do { > > > > result = r.exec(s); > > > > if (result!=null) > > trace(result[1]); > > > > }while(result!=null); > > } > > > > HTH. > > > > cheers, > > - shaun > > > > >

