A new version of the Google Site Search module for Joomla 2.5 was published get more infos here.

IT-Blog

PL/SQL Email-Validation

email

Sind years i have a simple Emai-check in my Toolbox. It is a simple PL/SQL function within a package. Two weeks ago i came about this regexp-page. There you can find a regexp that implements the RFC 2822 standard, or an more practical approach of it.  Since a time regular expressions are supported in PL/SQL, so i implemented it in my little email-check. I don't understand a lot of regexp and the regexp did not work out of the box, so a colleague helped me to correct and implement it for PL/SQL. The problem was a missing ^ at the start and the ?: in the regexp. The results are excellent! The regexp checks all official domains that are longer than 2 characters and also checks if the other domain are not longer than 2 characters. Give it a try!

Here is my code:

-- %author          Manfred Hofbauer (fairtec.at)
-- {*}CreateDate:   07.05.2006
-- {*}purpose:      function checks for an valid email (contains @ and ....)
-- %version         0.3
-- {*}ChangeHistory
-- {*}When          Who                     Version       purpose
-- {*}07.05.2006    Manfred Hofbauer        0.1           created
-- {*}03.12.2007    Manfred Hofbauer        0.2           changed to regexp
-- {*}05.12.2007    Manfred Hofbauer        0.3           returns number to be usable in SQL
-- %param           pEmail                  String that shall be checked for an valid email
-- %return          true or false (1=TRUE 0=False)
-- %raises
CREATE OR REPLACE FUNCTION isValidEmail (pEmail IN VARCHAR2) RETURN NUMBER IS

cEmailRegexp CONSTANT VARCHAR2(1000) := '^[a-z0-9!#$%&''*+/=?^_`{|}~-]+(\.[a-z0-9!#$%&''*+/=?^_`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+([A-Z]{2}|arpa|biz|com|info|intww|name|net|org|pro|aero|asia|cat|coop|edu|gov|jobs|mil|mobi|museum|pro|tel|travel|post)$';

BEGIN
IF REGEXP_LIKE(pEmail,cEmailRegexp,'i') THEN
RETURN 1;
ELSE
RETURN 0;
END IF;

-- !!!!DONT FORGET YOUR ERROR-HANDLING HERE!!!!
END isValidEmail;
/


  • Sarfraz Ramay

    Posted at 2009-12-03 06:25:45

    :o man this is awesome only a two line code! can you give a tutorial on how this works, i will be glad to learn. wht is REGEXP_LIKE, a built in procedure?

    Auf Kommentar antworten

  • emmy

    Posted at 2009-09-05 09:29:58

    :woohoo:

    Auf Kommentar antworten

Veröffentlichen Sie ihre Kommentare ...


Warning: Creating default object from empty value in /www/htdocs/w0101274/www/fairtec.at/modules/mod_udjacomments/helper.php on line 387