Oracle string processing practices

Source: Internet
Author: User

Background 1:

Personnel Information table, which contains the email_address field. The values in the field are in the following format:

Name1@test.com.cn or name2/test/COM/CN

Name of the target user.

The string processing function is as follows:

Code 1:

Select email_address
--, Instr (email_address, '@', 1, 1)
--, Decode (instr (email_address, '@'), 0, 'unadded @', substr (email_address, instr (email_address, '@'), length (email_address ))) judgment
, Replace (email_address
, Substr (
Email_address
, Decode (
Decode (
Instr (email_address ,'@')
, 0
, Instr (email_address ,'@')
, 0
)
, 0
, Instr (email_address ,'/')
)
, Length (email_address) + 1-Decode (
Decode (
Instr (email_address ,'@')
, 0
, Instr (email_address, '@'), 0
)
, 0
, Instr (email_address ,'/')
)
)
)
--, Decode (instr (email_address, '@'), 0, instr (email_address, '@'), 0), 0, instr (email_address ,'/'))
From ontact

-- Complex judgments are mainly used in decode determination. The score starts with '@' or '/'

 

Process 2:

Use regexp_replace

Select email_address, regexp_replace (email_address, '(@ |/) [A-Za-Z./@] *') from ca_contact

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.