0
在下面的代码中,如果我将st2替换为不带引号的正则表达式模式,它可以正常工作。 现在,因为我从其他文件中获得正则表达式,正如它在st2中所示。我想添加到正则表达式模式。但在下面的代码中,它不起作用。flex正则表达式,在正则表达式中添加一个可用的字符串
<fx:Script>
import mx.controls.Alert
public function onClicking(){
Alert.show("User says:" + textinput.text + " is new.");
}
public function checkValue(inputValue:String):void{
var st2="[0-9]|[12][0-9]|3[01]";
var pattern:RegExp = /^(st2)$/;
var str:String = textinput.text;
if(pattern.test(str)){
Alert.show("pass");
}
else{
Alert.show("fail");
}
}
</fx:Script>
谢谢Sly_cardinal。这是一个非常明确的解释。 – randeepsp 2012-01-02 04:25:45