Reputation: 425
I have a regular expression
select regexp_replace('[email protected] - work new address',
[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}, '')
from dual;
which i'm using to match email addresses. Some strings are stored as multilines
I want to match the email address on the 1st line and remove all text inlcuding - work, but NOT the second line after the carriage return.
Upvotes: 0
Views: 329
Reputation: 31
First you must replace carriage return with a caracter like #. For example :
REPLACE(yourstring,CHR(10),'#')
After with result string like "[email protected] - work#new@address" you can execute this :
select regexp_substr(regexp_substr('[email protected] - work#new@address',
'[^#]+', 1, level),'[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z] {2,4}')
from dual
connect by regexp_substr('[email protected] - work#new@address',
'[^#]+',1, level) is not null;
REGEXP_SUBSTR(REGEXP_SUBSTR('123
--------------------------------
[email protected]
new@address
Upvotes: 1