I am trying pull a field out of a string and return it.
My function:
public function getSubtype(ut:String):String {
var pattern:RegExp = new RegExp("X=(\w+)","i");
var nut:String = ut.replace(pattern, "$1");
trace("nut is " + nut);
return nut;
}
I'm passing it the string:
http://foo.bar.com/cgi-bin/ds.pl?type=boom&X=country&Y=day&Z=5
the trace statements return the above string with out modification.
I've tried the pattern out on Ryan Swanson's Flex 3 Regular Expresion Explorer and it returns: X=country. My wished for result is "country".
Must be obvious, but I can't see it. Any help will be appreciated.
TB
changed my function to the following and it works:
public function getSubtype2(ut:String):String {
trace("searching " + ut);
var pattern:RegExp = new RegExp("X=([a-z]+)");
var r:Object = pattern.exec(ut);
trace("result is " + r[1]);
return r[1].toString();
Interestingly, though, using X=(\w+) does not match and causes an error. ???? }