1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| 格式一:instr( string1, string2 ) / instr(源字符串, 目标字符串)
格式二:instr( string1, string2 [, start_position [, nth_appearance ] ] ) / instr(源字符串, 目标字符串, 起始位置, 匹配序号)
解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次出现string2。
SQL> select instr('helloworld','l') from dual;
INSTR('HELLOWORLD','L')
3
SQL> select instr('helloworld','lo') from dual;--在“lo”中,“l”开始出现的位置
INSTR('HELLOWORLD','LO')
4
SQL> select instr('helloworld','l',2,2) from dual;
INSTR('HELLOWORLD','L',2,2)
4
|