public static boolean isEmail ( String s ) { if ( isEmpty ( s ) ) return defaultEmptyOK ; // is s whitespace? if ( isWhitespace ( s ) ) return false ; // there must be >= 1 character before @, so we // start looking at character position 1 // (i.e. second character) int i = 1 ; int sLength = s . length ( ) ; // look for @ while ( ( i < sLength ) && ( s . charAt ( i ) != ' ' ) ) i ++ ; // there must be at least one character after the . if ( ( i >= sLength - 1 ) || ( s . charAt ( i ) != ' ' ) ) return false ; else return true ; // DEJ 2001-10-13 Don't look for '.', some valid emails do not have a dot in the domain name // else i += 2; // look for . // while((i < sLength) && (s.charAt(i) != '.')) i++; // there must be at least one character after the . // if((i >= sLength - 1) || (s.charAt(i) != '.')) return false; // else return true; }
Email address must be of form a