flex 正则表达式对空字符串的诡异判断

来源:互联网 发布:大学物理网络课程 编辑:程序博客网 时间:2024/06/06 03:28
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"minWidth="955" minHeight="600" layout="absolute"creationComplete="application1_creationCompleteHandler(event)"><mx:Script><![CDATA[import mx.events.FlexEvent;// when the RegExpValidator is set require = false and the test = "", it won't do the validator!protected function application1_creationCompleteHandler(event:FlexEvent):void{var regExp:RegExp = new RegExp("^[A-Za-z0-9]{1,8}$");trace(regExp.test("")); // false;trace(regExp.test(null)); // true !!!!!!!!!!!!!!!!!!!}]]></mx:Script></mx:Application>

0 0
原创粉丝点击