Re: pl/sql to validate email addresses

From: mgumbs <mgumbsNOmgSPAM_at_hotmail.com.invalid>
Date: Fri, 19 Nov 1999 05:39:52 -0800
Message-ID: <11f733ec.7cad4017_at_usw-ex0102-010.remarq.com>


I haven't got sql*plus in front of me at the mo to test this so the following could be a bit ropey! (I can't remember the order of parameters of the replace command, i think its right).

We can assume that an email address shouldn't have spaces or 2 _at_ signs. Returns TRUE if the address is valid.

Function Validate_Email(vEmailAddress in varchar2) return boolean is

  vBeforeLength number := 0;
  vAfterLength number := 0;

begin

  vBeforeLength := length(vEmailAddress);

  • Check for double _at_ signs

  vAfterLength := length(replace(vEmailAddress, '_at_@',''));   if vBeforeLength = vAfterLength then

     return FALSE;
  end if;

  • Check for spaces vAfterLength := length(replace(vEmailAddress, ' ','')); if vBeforeLength = vAfterLength then return FALSE; else return TRUE; end if;

end;

In article <3835477A.46C9E60D_at_sheffield.ac.uk>, j.m.whitehead_at_sheffield.ac.uk wrote:
> Does anybody know where I can get a pl/sql routine that will
> validate an
> entered email address? For example if somebody enters
> xyz_at_xyz.com
> it will accept it as valid but:
> xyz _at_ xyz . com
> wouldn't be accepted as valid. The validation doesn't need to be
> sophisticated just something that makes it hard for a user to
> enter a
> value that could never be a valid email address.
> TIA,
> Jon.

  • Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free!
Received on Fri Nov 19 1999 - 14:39:52 CET

Original text of this message