隨筆-109  評論-187  文章-25  trackbacks-0

          /**
          ?* user java reg to check phone number and replace 86 or +86
          ?* only check start with "+86" or "86" ex +8615911119999 13100009999 replace +86 or 86 with ""
          ?* @param phoneNum
          ?* @return
          ?* @throws Exception
          ?*/?
          ?protected int checkPhoneNum(String phoneNum) throws Exception {
          ??
          ??Pattern p1 = Pattern.compile("^((\\+{0,1}86){0,1})1[0-9]{10}");
          ??Matcher m1 = p1.matcher(phoneNum);
          ??if (m1.matches()) {
          ???Pattern p2 = Pattern.compile("^((\\+{0,1}86){0,1})");
          ???Matcher m2 = p2.matcher(phoneNum);
          ???StringBuffer sb = new StringBuffer();
          ???while (m2.find()) {
          ????m2.appendReplacement(sb, "");
          ???}
          ???m2.appendTail(sb);
          ???return Integer.parseInt(sb.toString());

          ??} else {
          ???throw new Exception("The format of phoneNum "+phoneNum+"? is not correct!Please correct it");
          ??}

          ?}

          posted on 2006-06-19 11:15 小小程序程序員混口飯吃 閱讀(8415) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 金山区| 玉溪市| 阜阳市| 阿拉善左旗| 上饶县| 常宁市| 海兴县| 庆安县| 自贡市| 时尚| 梨树县| 乌拉特中旗| 琼结县| 墨玉县| 泽普县| 灵山县| 博兴县| 长汀县| 西藏| 墨竹工卡县| 三穗县| 龙川县| 昆山市| 隆化县| 宜良县| 万全县| 璧山县| 彩票| 南漳县| 子洲县| 太和县| 沅江市| 北川| 丽水市| 高密市| 资兴市| 麻江县| 阿尔山市| 郸城县| 延津县| 樟树市|