Input |
|
Output |
|
Invalid |
|
|
valid |
|
|
Invalid |
|
|
valid |
|
|
Invalid |
|
|
Invalid |
Oracle & MySQL
with cte as (
select 'manvit@1' as email
from dual union all
select 'manvitla@2' as
email from dual union all
select 'manvitla#2' as
email from dual union all
select 'manvitlay@1' as
email from dual union all
select 'manvit@1ys' as
email from dual union all
select 'manvitl@y1' as
email from dual
)
select email,
case when REGEXP_LIKE(email, '^[A-Za-z]{8,}[^@]*@')=1
then 'valid' else 'invalid' end result
from cte;
PostgreSQL
with cte as (
select 'manvit@1' as email
union all
select 'manvitla@2' as
email union all
select 'manvitla#2' as
email union all
select 'manvitlay@1' as
email union all
select 'manvit@1ys' as
email union all
select 'manvitl@y1' as
email
)
select email,
case
when email ~ '^[A-Za-z]{8,}[^@]*@' then
'valid' else 'invalid' end result
from cte;
Explanation:
REGEXP_LIKE(email,
'^[A-Za-z]{8,}[^@]*@'): This condition checks if:
^:
The string starts with.
[A-Za-z]{8,}:
At least 8 alphabetic characters (both uppercase and lowercase).
[^@]*:
Any number of characters that are not @, ensuring that the sequence continues
until the @.
@:
The presence of the @ symbol following the alphabetic characters.
0 Comments
Thanks for your message.