2017-06-10 40 views

回答

0

你可以用regexp_substr()做到這一點。這裏有一個例子:

select translate(regexp_substr(email, '[.].*@', 1, 1), '[email protected]', 'x') 
from (select '[email protected]' as email from dual) x 
+0

反正是有使用SUBSTR和INSTR,並且不使用這些關鍵字 –

+0

@SyedAsadullahJ。 。 。是。 'regexp_substr()'通常比較簡單。 –

0
with data (val) as 
(
    select null from dual union all 
    select 'luvi.luci' from dual union all 
    select '[email protected]' from dual union all 
    select '[email protected]' from dual 
) 
-- step:1 
-- find the second group (\2) within the match 
-- ie. (any word/sequence of characters (\w+) flanked by a dot and a @) 
-- step:2 
-- |. OR any other character not matched in step:1 - will be ignored 
-- step:3 
-- \2 for each match found while parsing, for the entire match, 
--  replace it with the second group - so the dot and the @ are dropped from the match 
select val, regexp_replace (val, '(\.(\w+)@)|.', '\2') ss from data; 
相關問題