Here you can find the source of isValidEmail(final String email)
Parameter | Description |
---|---|
email entered by the user |
public static boolean isValidEmail(final String email)
//package com.java2s; /**// w w w . j a va2 s . co m * The contents of this file are subject to the OpenMRS Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://license.openmrs.org * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) OpenMRS, LLC. All Rights Reserved. */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { static Pattern pattern = Pattern.compile( "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$", Pattern.CASE_INSENSITIVE); /** * Validate the format of a user entered email * * @param email email entered by the user * @return true if the email is in good format */ public static boolean isValidEmail(final String email) { final Matcher matcher = pattern.matcher(email); return matcher.matches(); } }