Use of substr () in Oracle and InStr method in Oracle
Source: Internet
Author: User
inOracle/plsql, the
substrFunctions allows to extract a substring from a string.
The syntax for the
substrfunction is:
substr(String, start_position, [length])
Description
The string is the source string.
Start_position is the position for extraction. The position
inThe string is always 1.
The length is optional. It is the number of characters to extract. If This parameter is omitted,
substrWould return the entire string.
For example:
substr(' This is a test ', 6, 2) would return ' is '
substr(' is a test ', 6) would return ' is a test '
substr(' Techonthenet ', 1, 4) would return ' Tech '
substr(' Techonthenet ', -3, 3) would return ' Net '
substr(' Techonthenet ',-6, 3) would return ' the '
substr(' Techonthenet ',-8, 2) would return ' on '
INSTRMethod is formatted as
INSTR(Source string, target string, starting position, matching ordinal number)
For example:
INSTR(' CORPORATE FLOOR ', ' or ', 3, 2), the source string is ' CORPORATE FLOOR ', the target string is ' OR ', the starting position is 3, and the position of the 2nd match is taken.
The default lookup order is left to right. When the starting position is a negative number, start looking from the right.
So select
INSTR(' CORPORATE FLOOR ', ' OR ',-1, 1) The display result of the "instring" from dual is
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.