//正则表达式的使用
 public static void main(String[] args) throws IOException, ClassNotFoundException {
     //test1("123456");
     test2("-1  99     kk");
 }

 /**
  * 正则表达(校验qq号码)
  * 1.不能以0开头
  * 2.要求必须5-15位
  * 3.必须都是数字
  * [a-zA-Z] a 到 z 或 A 到 Z,两头的字母包括在内(范围)
  * X{n,m} X,至少 n 次,但是不超过 m 次
  * @throws IOException
  */
 private static void test1(String qq) throws IOException {
     boolean flag = qq.matches("[1-9][0-9]{4,14}");
     System.out.println(flag);
 }

 /**
  * 使用正则通过空格切割(一个或者多个空格)
  * @param str
  * @throws IOException
  */
 private static void test2(String str) throws IOException {
     String[] result = str.split(" +");
     for (String s : result) {
         System.out.println(result);
     }

 }
09-15 14:08