隨筆-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
          主站蜘蛛池模板: 宁陕县| 永州市| 育儿| 侯马市| 墨江| 利辛县| 襄樊市| 阿拉尔市| 克东县| 西华县| 南乐县| 韶关市| 上蔡县| 栾川县| 宁津县| 剑阁县| 新密市| 莱西市| 松江区| 阜南县| 新绛县| 芦山县| 双城市| 宣汉县| 敖汉旗| 邛崃市| 法库县| 龙里县| 四子王旗| 习水县| 静海县| 如东县| 田阳县| 墨脱县| 科技| 呼和浩特市| 灵武市| 绥滨县| 公主岭市| 仪征市| 壶关县|