求写一个正则表达式,任意位数的数字-任意位数的数字。只能是数字,可以0开头。比如:
0123-01234560
19条回答
grace.free 2018-08-06 06:14关注public static void main(String[] args) { String str = "0123-01234560"; String regEx = "[0-9]*-[0-9]*"; Pattern pattern = Pattern.compile(regEx); Matcher matcher = pattern.matcher(str); boolean rs = matcher.matches(); System.out.println(rs); }评论 打赏 举报解决 1无用