微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

<?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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐