Some String Modification Functions in ORACLE

1. Oracle's substr() function

Function: Returns a substring from the given character expression or memo field.
Expression 1: SubStr(character set, start position, end position);
Expression 2: SubStr(character set, interception position);
Expression 3; SubStr ( char A, char B, int C, int D)
 Function description of expression 3: Starting from the Cth character of string B, intercept a string of length D, and put the character In the string array A, return the intercepted string. 
Example: mystring = 'abcd ef ghijklm' ;

SUBSTR(mystring,1,5) displays "abcde"
   SUBSTR(mystring,6) displays "fghijklm"
   SUBSTR(mystring,-2) displays "lm"
   SUBSTR(mystrng,-4) displays "jklm" 2. Oracle's instr() function usage Function description: You can use the instr function to judge a string to determine whether it contains the specified character. Finds the specified character in a string and returns the position of the specified character found. Syntax: instr(sourceString,destString,start,appearPosition)  where sourceString represents the source string; 
destString represents the substring to be searched from the source string; 
start represents the starting position of the search, this parameter is optional, the default is 1; 
appearPosition Indicates that you want to find the destString of the first occurrence of the source character. This parameter is also optional. The default value is 1. 
If the value of start is negative, it means that the search is performed from right to left, but the position data is still calculated from left to right. . 
The return value is: the position of the found string.  For the instr function, we often use it like this: find the position of the specified substring from a string. For example: 
SQL> select instr('abcdefgh','de') position from dual; ----The return value is 4,
and d is the fourth from 1, so it returns 4 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326134430&siteId=291194637