HI MM,
Oke, i think you can, since it matches the input given with the case.
i didnt test it.
But cant you store the regex in a var and put that in the case?
like so:
var myRegEx:RegExp = /(W|M|K)\d/i;
var stringToMatch = "";
switch(stringToMatch) {
case myRegEx:
break;
}
Otherwise cant you swithc on the result of the executed regex?
Let me know if it helps,
Sid
On May 15, 2009, at 4:52 PM, Mendelsohn, Michael wrote:
Thanks for responding Sidney. I think if I set a var prior to the
switch, it might not work because there are so many strings going
into the switch. I'm trying to optimize this that would apply to
only some of all the cases:
switch(str){
case ("W1") :
case ("W2") :
case ("W3") :
break;
case ("M1") :
case ("M2") :
case ("M3") :
break;
case ("K1") :
case ("K2") :
case ("K3") :
break;
}
}
...into something shorter like this:
switch(str){
case(/(W|M|K)\d/i):
break;
}
I think its better practice to define that regex in a variable and
switch on that variable.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Sidney de Koning - be a geek, in rockstar style!
Flash / AIR Developer @ www.funky-monkey.nl
Technical Writer @ www.insideria.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders