I am not entirely sure you can accomplish this within your regular expression. However, you could add an additional filter as below:
SELECT * FROM table_name
WHERE REGEXP_LIKE(column_name,'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$')
AND REPLACE(TRANSLATE(LOWER(column_name), 'abcdefghijklmnopqrstuvwxyz0123456789@+.-_%','zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'),'z') IS NOT NULL
The TRANSLATE()
function will replace all of the "regular" letters (plus the characters ordinarily allowed in email addresses; I think I've gotten them all) with 'z's; the REPLACE()
function replaces these with nothing; if the resulting string IS NOT NULL
then there are "special" characters.
I could not confirm that this actually works since the character set in my database is ASCII and doesn't return "special" characters for the regex. But I confirmed that the REPLACE(TRANSLATE())
clause does work:
WITH t1 AS (
SELECT 'FRANÞOISVERBEKE@TISCALINET.BE' AS mycolumn FROM dual
)
SELECT mycolumn
, REPLACE(TRANSLATE(LOWER(mycolumn),'abcdefghijklmnopqrstuvwxyz0123456789@+.-_%','zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'),'z') AS mynewcolumn
FROM t1
WHERE REPLACE(TRANSLATE(LOWER(mycolumn),'abcdefghijklmnopqrstuvwxyz0123456789@+.-_%','zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'),'z') IS NOT NULL
Result:
MYCOLUMN MYNEWCOLUMN
FRANÞOISVERBEKE@TISCALINET.BE þ