package cn.hmsoft.ltc.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {

	/**
	 * 正数
	 * @param str
	 * @return
	 */
	public static boolean isPositiveNumber(String str) {
		if (str == null) {
			return false;
		}
		str = str.trim();
		Pattern pattern = Pattern.compile("[0-9]*");
		Matcher isNum = pattern.matcher(str);
		return isNum.matches();
	}
	
	/**
	 * 浮点数
	 * @param str
	 * @return
	 */
	public static boolean isFloatNumber(String str) {
		if (str == null) {
			return false;
		}
		str = str.trim();
		Pattern pattern = Pattern.compile("^[1-9]\\d*\\.{0,1}\\d*|0\\.{0,1}\\d*[1-9]\\d*$");
		Matcher isNum = pattern.matcher(str);
		return isNum.matches();
	}
	
	public static void main(String[] args) {

		System.err.println(isPositiveNumber("22"));
	}
}
