现在的位置: 首页 > 综合 > 正文

regex判断数字

2013年08月06日 ⁄ 综合 ⁄ 共 226字 ⁄ 字号 评论关闭
public class Test {
    public static void main(String[] args) {
        String a = "-1";
         Pattern p = Pattern.compile("[0-9]*|-[0-9]*");
         Matcher m = p.matcher(a);
         boolean b = m.matches();
         System.out.println(b);
    }
}
判断是否是多个整数或负数

抱歉!评论已关闭.