Wendymb
Wendymb

Reputation: 1

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 ([email protected]) to this: [email protected]

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 ([email protected])', '[^("]+',1,2)
FROM dual;

REGEXP_SUBSTR('STUART,MARTING(
------------------------------
[email protected])

Upvotes: 0

Views: 69

Answers (2)

sql_dummy
sql_dummy

Reputation: 739

 select regexp_substr ('Stuart, Martin G ([email protected])', '[^()]+',1,2) from dual;   

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

Upvotes: 0

Multisync
Multisync

Reputation: 8797

select regexp_substr ('Stuart, Martin G ([email protected])', '[^)("]+',1,2) from dual;

Just add the closing bracket inside [^]

Upvotes: 1

Related Questions