1

I am trying to find double dots, if consecutive double dot exits in any email it should prompt me with "NO"

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 protected]';
if regexp_like(v_email, v_constant) then

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

Note: Double dot means consecutive dots and presence of double dots needs to be checked before "@"

Tried using Regex that does not allow consecutive dots

Could not find the proper placement of regex.

Kindly help.

2

2 Answers 2

1

My immediate idea is just to check if the index of ".." is less than the index of "@", and that the first index is not -1.

SELECT
    CASE WHEN INSTR(v_email, '..') BETWEEN 1 AND INSTR(v_email, '@') - 1
         THEN 'dots present'
         ELSE 'no dots' END AS dots
FROM yourTable;

I hope this is of help to you :)

Sign up to request clarification or add additional context in comments.

Comments

0

Change this part:

([a-zA-Z0-9_\.\/%+="''\-]*[a-zA-Z0-9])

To this:

((\.?[a-zA-Z0-9_\/%+="''\-]+)*\.?[a-zA-Z0-9])

So basically, if there are any dots to match, they must be interspersed with some number of non-dot, acceptable characters. That way you will never match two consecutive ones.

1 Comment

Request you to look into Question No. 47416137

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.