I have a regular expression
select regexp_replace('123@gmail.com - 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.
First you must replace carriage return with a caracter like #. For example :
REPLACE(yourstring,CHR(10),'#')
After with result string like "123@gmail.com - work#new@address" you can execute this :
select regexp_substr(regexp_substr('123@gmail.com - work#new@address',
'[^#]+', 1, level),'[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z] {2,4}')
from dual
connect by regexp_substr('123@gmail.com - work#new@address',
'[^#]+',1, level) is not null;
REGEXP_SUBSTR(REGEXP_SUBSTR('123
--------------------------------
123@gmail.com
new@address
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.