Oracle string interception from backward forward interception method ____oracle

Source: Internet
Author: User

Oracle string interception from backward forward method

The format of the Instr:instr method is

INSTR (source string, target string, start position, match ordinal)

The default lookup order is left to right. When the starting position is a negative number, start looking from the right.

SUBSTR: Fetching substring string

SUBSTR (source string, starting position, number of bits to take)

From start position, take "how many"

Select ' za01x-00000 ' as Item_code
, InStr (' za01x-00000 ', ' -00000 ', -1,1) as position
, substr (' za01x-00000 ', InStr (' za01x-00000 ', ' -00000 ', -1,1), Length (' za01x-00000 ')) as result
From dual
;

--
Item_code POSITION Result
za01x-00000 6-00000
--
Select substr (' za01x-00000 ', -6) as result
From dual
;
--
Result
-00000
--

--to intercept the '-00000 ' string in item CODE


--Liu Yihe

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.