隨筆-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
          主站蜘蛛池模板: 民县| 曲麻莱县| 瑞安市| 花莲市| 西昌市| 合山市| 车致| 青阳县| 富民县| 湟中县| 西贡区| 惠东县| 南陵县| 禹城市| 光泽县| 佳木斯市| 磐安县| 兰考县| 辉南县| 准格尔旗| 通化市| 屯门区| 临邑县| 芮城县| 阳西县| 偏关县| 岳阳县| 大名县| 和平县| 清水河县| 拉孜县| 长葛市| 沾益县| 和林格尔县| 兴宁市| 古蔺县| 乌恰县| 五原县| 彰武县| 永新县| 松原市|