p27
p27

Reputation: 2222

plsql get particular sub string from givin string

I have a input string like following

'"sadf asd " <[email protected]>'
'"[email protected] " <[email protected]>'

now i want to extract email address as following:

[email protected]
[email protected]

how can i get it ?

Upvotes: 0

Views: 29

Answers (2)

Walter_Ritzel
Walter_Ritzel

Reputation: 1397

Here is a way:

select replace(replace(REGEXP_SUBSTR('"[email protected] " <[email protected]>','[<](\w+@(\w*.\w*)+)[>]'),'<',''),'>','')
from dual

This will return [email protected]

Upvotes: 1

Aleksej
Aleksej

Reputation: 22949

Assuming that the address is always quoted by <...> and that there are no '<' or '>' in the first part of the string, you can use:

select regexp_replace('"[email protected] " <[email protected]>', '(.*)<(.*)>', '\2')
from dual

Upvotes: 1

Related Questions