Saturday, December 22, 2018

regex to check valid email in oracle

Below regex is validating almost all valid and invalid email addresses mentioned at :https://blogs.msdn.microsoft.com/testing123/2009/02/06/email-address-test-cases/



Code:



DECLARE 
v_email webowner.person.email%TYPE;

v_constant CONSTANT VARCHAR2(300) := '^(([a-zA-Z0-9"_\-])((\.?[a-zA-Z0-9_\/%+="''\-]+)\.?[a-zA-Z0-9+-]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\]))$';
BEGIN
v_email := 'email@domain.com';
if regexp_like(v_email, v_constant) then

pl('YES: ' || v_email);
else
pl('NO: ' || v_email);
end if;
END;



But the condition now arises, it is expecting minimum of 2 characters(in username part before "@") whereas I need to have only one mandatory character.



e.g.



p@domain.com

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...