Oracle函数--instr()

来源:互联网 发布:js 不区分大小写判断 编辑:程序博客网 时间:2024/06/07 00:23


instr() 返回要截取的字符串在源字符串中的位置

语法: 
instr(sourceString,destString,startPosition,appearPosition) 

参数说明:

sourceString:源字符串,要在此字符串中查找。

destString:要在sourceString中查找的字符串。

startPosition:代表在sourceString字符串中哪个位置开始查找。此参数可选,如果忽略默认为1.如果此参数为正数,从左向右检索。如果为负数,从右向左检索。返回查找字符串在源字符串中的索引位置。

appearPosition:代表查找第几次出现的destString,此参数可以忽略,默认为1,设置负数会报错。

如果destString在sourceString没有查找到,则返回0.

Both sourceString and destString  can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, orNCLOB. The value returned is of NUMBER datatype.

--返回要截取的字符串在源字符串中的位置
select instr('abc','a') from dual;                 --返回1
select instr('abc','bc') from dual;               --返回2
select instr('aB c abc','a',1,2) from dual;  --返回6
select instr('uoabc','bc',-1,1) from dual;   --返回4
select instr('abc','d') from dual;            --返回0


扩展:instrb(),instrc(),instr2(),instr4()





原创粉丝点击