如何验证所有教育领域

时间:2019-04-24 00:14:04

标签: java regex email rfc822

我试图在邮件中验证域edu和所有子域,但无法识别子域

正则表达式在edu之后无法识别我

Pattern p_correo1 = Pattern.compile("^[a-zA-Z]\\.[a-zA-Z]\\.(?:2019|20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})@([0-9]|[a-z]|[A-Z])+\\.edu\\.?[a-z]?$");

private void btn_validarActionPerformed(java.awt.event.ActionEvent evt) {                                            

    String w_correo = caja_correo.getText();
    Pattern p_correo1 = Pattern.compile("^[a-zA-Z]\\.[a-zA-Z]\\.(?:2019|20[2-9][0-9]|2[1-9][0-9]{2}|[3-9][0-9]{3})@([0-9]|[a-z]|[A-Z])+\\.edu.?[a-z]?$");
    Matcher m_correo1 = p_correo1.matcher(w_correo);
    Pattern p_correo2 = Pattern.compile("^(?:2018|201[0-7]|200[0-9]|1[0-9]{1,3}|[0-9]{1,3})\\.[a-zA-Z]\\.[a-zA-Z]@\\w+(?:\\.\\w+)*\\.com\\.co$");
    Matcher m_correo2 = p_correo2.matcher(w_correo);    
    int lenght = w_correo.length();

    System.out.println(w_correo.length());

    if (m_correo1.matches()|| m_correo2.matches()) {                     
        String validacion = "";
        validacion = validacion +  "Direccion de correo electrónico correcta<br/>";
        correcto.setForeground(Color.GREEN);
     } else { 
        String validacion = "";
        if (!m_correo1.matches() || m_correo2.matches()) {
            validacion= validacion + "Direccion de correo electrónico incorrecta<br/>";
            incorrecto.setBackground(Color.RED);
        }
    }
}                  

我必须进行更改以便识别任何子域edu,例如edu.uk等。

0 个答案:

没有答案