隨筆-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 小小程序程序員混口飯吃 閱讀(8408) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 镇江市| 资溪县| 理塘县| 行唐县| 博爱县| 阿图什市| 宽甸| 金秀| 新田县| 烟台市| 隆德县| 沅江市| 海林市| 任丘市| 吉安县| 精河县| 连江县| 航空| 余庆县| 鸡泽县| 神农架林区| 固镇县| 淳化县| 辽阳市| 荆门市| 西林县| 新平| 南皮县| 达拉特旗| 沭阳县| 建始县| 马龙县| 广汉市| 丹江口市| 绥宁县| 郯城县| 土默特左旗| 勃利县| 浙江省| 精河县| 咸丰县|