2008. 11. 14. 15:19

email 체크 정규식*Java

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public boolean isValidEmail() {
  boolean err = false;
  String regex = "^[_a-z0-9-]+(.[_a-z0-9-]+)*@(?:\\w+\\.)+\\w+$";

        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(inputStr);
        if( !m.matches() ) {
      String[] params = new String[] { item };
      DialogManager.showMessage(comp, DialogManager.ERROR_INPUT_INVALID_EMAIL, params);
      err = true;
        }
        return err;
 }