package com.hmsoft.common.util;

import java.util.regex.Pattern;

/**
 * 
 * @author zhanq
 *
 */
public class RegexpUtils {
	/**
	 * 包含0的整数
	 */
	public static String intRex = "^\\d+$";
	/**
	 * 非0正整数
	 */
	public static String intRexGtZero = "^[1-9]\\d*$";
	
	public static final String positiveIntRegx = "^[0-9]*[1-9][0-9]*$";
	public static final String positiveFloatRegx = "([0-9]\\d*\\.?\\d*)";
	
	/**
	 * 正整数,包括0.
	 * @param intVal
	 * @return
	 */
	public static boolean checkIsPositiveInt(final String intVal) {
		return Pattern.matches(intRex, intVal);
	}
	
	/**
	 * 正整数，大于0.
	 * @param intVal
	 * @return
	 */
	public static boolean checkIsPositiveIntGtZero(final String intVal) {
		return Pattern.matches(intRexGtZero, intVal);
	}
	
	/**
	 * 正整数，或正浮点数.
	 * @param floatVal
	 * @return
	 */
	public static boolean checkIsPositiveFloat(final String floatVal) {
		return Pattern.matches(positiveFloatRegx, floatVal);
	}
	
	public static void main(String[] args) {
		System.err.println(checkIsPositiveIntGtZero("-1"));
	}
}
