Oracle Intercept, find character functions (continuous update)

Source: Internet
Author: User

Organize some of the commonly used intercept and find character functions:

1. Find the number of occurrences of a character (string) in a string

SELECT LENGTH (regexp_replace (' Anne<br>lily<br>jane ', ' <br> ', ' @ '), ' [^@]+ ', ') ') COUNT from DUAL; --Return 2

2. Determine if a character has occurred in the source string
Select InStr (' Anne<br>lily<br>jane ', ' <br> ', 1) from dual--return 5

3. When a character appears multiple times in the source string, remove the last one (provided that the repeating character is bound to appear at the end of the source string)
SELECT SUBSTR (' anne<br>lily<br>jane<br> ', 1, (LENGTH (' anne<br>lily<br>jane<br > ')-length (' <br> '))) from dual--back to Anne<br>lily<br>jane

4. When a special symbol appears multiple times in the source string, only the number of digits behind the first occurrence is intercepted
Select substr (' Adssf.anne.aaaa ', 1,instr (' adssf.anne.aaaa ', '. ', 1) +3) from dual--return to Adssf.ann

Select substr (' asdfanne-asdfe-123456 '
, InStr (' asdfanne-asdfe-123456 ', '-', 1) +1
, Length (' asdfanne-asdfe-123456 ')-instr (' asdfanne-asdfe-123456 ', '-', 1) +1
) from dual--return to asdfe-123456

Oracle Intercept, find character functions (continuous update)

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.