简体   繁体   English

Oracle SQL regexp_substr编程问题

[英]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. 我是编程方面的新手,我正在查询中使用REGEXP_SUBSTR。 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 我想将其转换为:Martin E. Stuart,Martin E(Martin.Stuart@canadanotes.ca)转换为: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. 我正在使用regexp_substr并显示所有内容,但我需要删除的电子邮件地址末尾有一个令人讨厌的括号。 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. 以及为什么在表达式中使用文字“”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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