Android 郵箱驗證

boolean checkUserName(EditText editText) {
       String userName = editText.getText().toString().trim();
       errrToast(userName);
       /*
        * 正則表達式 測試 郵箱是否合法
        */
       Pattern pattern = Pattern.compile(
               "[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+",
               Pattern.CASE_INSENSITIVE);
       Matcher matcher = pattern.matcher(userName);
       if (matcher.matches()) {
           return true;
       }
       errrToast("郵箱格式輸入錯誤");
       return false;
   }
正則表達式

相關文章
相關標籤/搜索