隨筆-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 小小程序程序員混口飯吃 閱讀(8407) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 新津县| 德令哈市| 隆林| 瓮安县| 海伦市| 枞阳县| 延安市| 石屏县| 天峻县| 涪陵区| 江川县| 项城市| 左权县| 平塘县| 吉林市| 永登县| 肇东市| 永年县| 繁昌县| 永昌县| 明水县| 汶上县| 银川市| 大连市| 靖西县| 平塘县| 门头沟区| 绥棱县| 衡东县| 东兴市| 商南县| 宽甸| 乌兰县| 崇文区| 浪卡子县| 达州市| 来宾市| 溧水县| 卢龙县| 罗平县| 宜章县|