Here you can find the source of isValidEmailAddr(String str)
public static final boolean isValidEmailAddr(String str)
//package com.java2s; /**// w ww. j a v a2 s . c o m * This file is part of the Gribbit Web Framework. * * https://github.com/lukehutch/gribbit * * @author Luke Hutchison * * -- * * @license Apache 2.0 * * Copyright 2015 Luke Hutchison * * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.regex.Pattern; public class Main { /** * Pattern for valid email address: from http://www.regular-expressions.info/email.html . * * N.B. this is different than the validation performed by Chrome's type="email" form field validation (it * pretty much only requires an '@' character somewhere), so it's possible to submit form data like "x@y" that * passes Chrome's validation but fails serverside validation. */ public static final Pattern VALID_EMAIL_ADDRESS = Pattern .compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" + "@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"); /** Returns true iff str is a valid email address. */ public static final boolean isValidEmailAddr(String str) { return str != null && VALID_EMAIL_ADDRESS.matcher(str).matches(); } }