Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regexp match a domain and its subdomain

user13117585Feb 13 2018 — edited Feb 14 2018

Hello,

I have a REGEXP question. Hope someone could help. I'm trying to match domain. I'm trying to get all the email with domains @mydomain.fr

The problem is that I also need to match

- @foo.mydomain.fr

- @bar.mydomain.fr

But not

email@zdomain.fr

I tried the following but it also matched the email@zdomain.fr.

WITH t AS

(

  SELECT 'email@domain.fr' AS email FROM dual UNION ALL

  SELECT 'email@foo.domain.fr' AS email FROM dual UNION ALL

  SELECT 'email@bar.domain.fr' AS email FROM dual UNION ALL

  SELECT 'email@zdomain.fr' AS email FROM dual

)

SELECT email, 1

  FROM t

WHERE REGEXP_LIKE(email, '*(\.)?domain.fr', 'i') ;

I read my REGEXP like this: email starts with anything; followed by a dot (optional) and then domain.fr case insensitive. Isn't it right ??

Anyone can tell me what I'm doing wrong?

Thanks,

This post has been answered by GregV on Feb 13 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2018
Added on Feb 13 2018
9 comments
2,395 views