Put that logic in a function that returns a Boolean, so you can debug
it.  Then use the function in the e4x expression.

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 

________________________________

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of plugsymmv
Sent: Monday, January 12, 2009 5:28 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] E4X with RegExp

 

I'm having trouble parsing some XML. 

This works 
var xL0:XMLList=inputXML..node.(/^Gear[0-9]{2}W$/.(test(@name)));

This is apparently should work with a compiler warning

public static const GEARDEF1:RegExp=new RegExp("/^Gear[0-9]{2}$/","i");
var xL2:XMLList=inputXML..node.(GEARDEF1.test(@name));

and using square bracketing like this should work and stop the warnings.
public static const GEARDEF1:RegExp=new RegExp("/^Gear[0-9]{2}$/","i");
var xL2:XMLList=inputXML..node.(GEARDEF1["test"](@name));

Trouble is neither of the two methods using RegExp work - which if it
were that simple wouldn't matter. The reason for this is that I need
to build arrays of RegExs to loop over like this.
public static const GEARDEF1:RegExp=new RegExp("/^Gear[0-9]{2}$/","i");
public static const GEARDEF2:RegExp=new RegExp("/^Gear[0-9]{2}W$/");
public static const GEARDEF3:RegExp=new RegExp("/^Gear[0-9]{2}01Loc$/");
public static var geardefs:Array =[GEARDEF1, GEARDEF2, GEARDEF3];

Any suggestions as to why this doesn't work?

 

Reply via email to