I want to get e-mail formed texts in a field. I have tried sql below but no luck. See SqlFiddle. Removing ^ and $ from regexp not working too.
WITH TEST_DATA AS (
SELECT '[email protected]' AS EMAIL FROM DUAL UNION ALL
SELECT 'mail [email protected]' FROM DUAL UNION ALL
SELECT 'mail [email protected] sent' FROM DUAL UNION ALL
SELECT '[email protected] sent count 23' FROM DUAL UNION ALL
SELECT 'mail already sent to [email protected] and [email protected]' FROM DUAL UNION ALL
SELECT '[email protected] sent count 23' FROM DUAL
)SELECT REGEXP_SUBSTR(EMAIL,'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$') MAIL
FROM TEST_DATA;
Expected output for this dataset
[email protected]
[email protected]
[email protected]
[email protected]
[email protected], [email protected]
[email protected]
Any help appreciated.
[email protected]. Also, I'm guessing here, but I think your regex will not pick emails like[email protected]. Email recognition in regex is incredibly hard, and prone to errors, I wish you luck.