網站首頁 編程語言 正文
instr函數為字符查找函數,其功能是查找一個字符串在另一個字符串中首次出現的位置。instr函數在Oracle/PLSQL中是返回要截取的字符串在源字符串中的位置。
字符串的位置是從1開始數instr(str1,str2)計算得出的是后一字符串str2在前一字符串str1中首次出現的位置若沒有找到,會返回0
instr()函數的格式:
格式一:instr( string1, string2 )
含義:instr(源字符串, 目標字符串)
格式二:instr( string1, string2 , start_position , nth_appearance )
含義:instr(源字符串, 目標字符串, 起始位置, 匹配序號)
解析:string2 的值要在string1中查找,是從start_position給出的數值(即:位置)開始在string1檢索,檢索第nth_appearance(幾)次出現string2。
注:在Oracle/PLSQL中,instr函數返回要截取的字符串在源字符串中的位置。 只檢索一次,也就是說從字符的開始到字符的結尾就結束。
格式一實例:
1、 select instr('helloworld','l') from dual; --返回結果:3 默認第一次出現“l”的位置 2、 select instr('helloworld','lo') from dual; --返回結果:4 即:在“lo”中,“l”開始出現的位置 3、 select instr('helloworld','wo') from dual; --返回結果:6 即“w”開始出現的位置
格式二實例:
1、 select instr('helloworld','l',2,2) from dual; --返回結果:4 也就是說:在"helloworld"的第2(e)號位置開始,查找第二次出現的“l”的位置 2、 select instr('helloworld','l',3,2) from dual; --返回結果:4 也就是說:在"helloworld"的第3(l)號位置開始,查找第二次出現的“l”的位置 3、 select instr('helloworld','l',4,2) from dual; --返回結果:9 也就是說:在"helloworld"的第4(l)號位置開始,查找第二次出現的“l”的位置 4、select instr('helloworld','l',-1,2) from dual; --返回結果:4 也就是說:在"helloworld"的倒數第1(d)號位置開始,往回查找第二次出現的“l”的位置 5、 select instr('helloworld','l',-2,2) from dual; --返回結果:4 和第四個一樣 6、 select instr('helloworld','l',2,3) from dual; --返回結果:9 也就是說:在"helloworld"的第2(e)號位置開始,查找第三次出現的“l”的位置 7、 select instr('helloworld','l',-2,3) from dual; --返回結果:3 也就是說:在"helloworld"的倒數第2(l)號位置開始,往回查找第三次出現的“l”的位置
資料來源:
Oracle中的instr函數
Oracle中的instr()函數
原文鏈接:https://blog.csdn.net/qq_34626094/article/details/127947284
相關推薦
- 2022-03-16 C語言庫函數中qsort()的用法_C 語言
- 2022-06-07 詳解ASP.NET?Core高性能服務器HTTP.SYS_實用技巧
- 2022-05-31 詳解Flutter如何繪制曲線,折線圖及波浪動效_Android
- 2023-10-28 C語言中getchar函數詳解看這一篇就夠了(函數功能、使用、返回值)_C 語言
- 2022-08-21 python數字圖像處理之基本形態學濾波_python
- 2023-06-19 C++中的策略模式淺析_C 語言
- 2022-10-31 Golang?template?包基本原理分析_Golang
- 2022-06-12 postgreSQL數據庫基本概念教程_PostgreSQL
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支