简体   繁体   中英

Oracle SQL regexp_substr programming issue

Can anyone help me solve this? I'm a bit of a newbie in programming and I'm looking at using REGEXP_SUBSTR in my query. I have a large file and I need to use only certain parts.

I want to convert this: Stuart, Martin E (Martin.Stuart@canadanotes.ca) to this: Martin.Stuart@canadanotes.ca

I'm using regexp_substr and have got it to display everything apart but I have an annoying bracket on the end of the email address I need to get rid of. Can anyone help please?

SELECT regexp_substr ('Stuart, Martin G (Martin.Stuart@canadanotes.ca)', '[^("]+',1,2)
FROM dual;

REGEXP_SUBSTR('STUART,MARTING(
------------------------------
Martin.Stuart@canadanotes.ca)
select regexp_substr ('Stuart, Martin G (Martin.Stuart@canadanotes.ca)', '[^)("]+',1,2) from dual;

只需在[^]内添加右括号

 select regexp_substr ('Stuart, Martin G (Martin.Stuart@canadanotes.ca)', '[^()]+',1,2) from dual;   

works fine. And why are using the literal " in the expression.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM