zoukankan      html  css  js  c++  java
  • 验证IP是否合法

    package check
    {
    	import mx.events.ValidationResultEvent;
    	import mx.validators.RegExpValidator;
    	
    	public class Check
    	{
    		var regExpValidator:RegExpValidator=new RegExpValidator;
    		
    		public function is_Ip(ip:Object):Boolean{
    			var result:Boolean=true;
    			this.regExpValidator.property="text";
    			this.regExpValidator.source=ip;
    			this.regExpValidator.expression="^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1})\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]{1}|0[1-9]{1}[0-9]{1}|00[1-9]{1}|0)$";
    			this.regExpValidator.noMatchError="格式错误";
    			
    			var event:ValidationResultEvent=this.regExpValidator.validate();
    			if(event.type==ValidationResultEvent.INVALID){
    				result=false;
    			}
    			return result;
    		}
    
    	}
    }
  • 相关阅读:
    Codeforces Round #564(div2)
    714
    1471
    UVa 11134
    UVa 1152 -4 Values whose Sum is 0—[哈希表实现]
    UVa 1374
    UVA 1343
    UVa 12325
    Yet Another Number Sequence——[矩阵快速幂]
    River Hopscotch-[二分查找、贪心]
  • 原文地址:https://www.cnblogs.com/frostbelt/p/1880897.html
Copyright © 2011-2022 走看看