Oracle的REGEXP_SUBSTR函数简单使用方法
REGEXP_SUBSTR延伸SUBSTR函数的功能。让你搜索一个正則表達式模式字符串。
这也相似于REGEXP_INSTR。而是返回子字符串的位置,它返回的子字符串本身。
语法
Oracle数据库中的REGEXP_SUBSTR函数的语法是:
REGEXP_SUBSTR(source_char, pattern [, position [, occurrence [, match_parameter ]]])
參数
source_char
搜索字符串。能够是随意的数据类型char。VARCHAR2。nchar,CLOB,NCLOB类型
pattern
正則表達式
| Value | Description |
| ^ | Matches the beginning of a string. If used with a match_parameter of ‘m’, it matches the start of a line anywhere within expression. |
| $ | Matches the end of a string. If used with a match_parameter of ‘m’, it matches the end of a line anywhere within expression. |
| * | 匹配零个或多个. |
| + | 匹配一个或多个出现. |
| ? | 匹配零次或一次出现. |
| . | 匹配不论什么字符,除了空. |
| | | Used like an "OR" to specify more than one alternative. |
| [ ] | Used to specify a matching list where you are trying to match any one of the characters in the list. |
| [^ ] | Used to specify a nonmatching list where you are trying to match any character except for the ones in the list. |
| ( ) | Used to group expressions as a subexpression. |
| {m} | Matches m times. |
| {m,} | Matches at least m times. |
| {m,n} | Matches at least m times, but no more than n times. |
| \n | n is a number between 1 and 9. Matches the nth subexpression found within ( ) before encountering \n. |
| [..] | Matches one collation element that can be more than one character. |
| [::] | Matches character classes. |
| [==] | Matches equivalence classes. |
| \d | 匹配一个数字字符. |
| \D | 匹配一个非数字字符. |
| \w | 匹配包含下划线的不论什么单词字符. |
| \W | 匹配不论什么非单词字符. |
| \s | 匹配不论什么空白字符。包含空格、制表符、换页符等等. |
| \S | 匹配不论什么非空白字符. |
| \A | Matches the beginning of a string or matches at the end of a string before a newline character. |
| \Z | Matches at the end of a string. |
| *? | Matches the preceding pattern zero or more occurrences. |
| +? | Matches the preceding pattern one or more occurrences. |
| ?? | Matches the preceding pattern zero or one occurrence. |
| {n}? | Matches the preceding pattern n times. |
| {n,}? | Matches the preceding pattern at least n times. |
| {n,m}? | Matches the preceding pattern at least n times, but not more than m times. |
position
可选。搜索在字符串中的開始位置。假设省略,默觉得1。这是第一个位置的字符串。
occurrence
可选。它是模式字符串中的第n个匹配位置。假设省略。默觉得1。
match_parameter
可选。它同意你改动regexp_substr功能匹配的行为。它能够是以下的组合:
| Value | Description |
| ‘c’ | 区分大写和小写的匹配. |
| ‘i’ | 不区分大写和小写的匹配. |
| ‘n’ | Allows the period character (.) to match the newline character. By default, the period is a wildcard. |
| ‘m’ | expression is assumed to have multiple lines, where ^ is the start of a line and $ is the end of a line, regardless of the position of those characters in expression. By default, expression is assumed to be a single line. |
| ‘x’ | Whitespace characters are ignored. By default, whitespace characters are matched like any other character. |
Examples
找出匹配的数字
SELECT REGEXP_SUBSTR ('hello my phone is 520 ', '[0-9]+') FROM dual; --520
以下这个样例返回指定第三次出现的字符
SELECT REGEXP_SUBSTR ('i like beijing tiananmen', '(\S*)(\s)', 1, 3)
FROM dual; --beijing
作者:itmyhome
Oracle的REGEXP_SUBSTR函数简单使用方法的更多相关文章
- Oracle的REGEXP_INSTR函数简单使用方法
REGEXP_INSTR函数让你搜索一个正則表達式模式字符串. 函数使用输入字符集定义的字符进行字符串的计算. 它返回一个整数,指示開始或结束匹配的子位置.这取决于return_option參数的值. ...
- Oracle中REGEXP_SUBSTR函数(转)
Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下:在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20','2 ...
- 数据库迁移之从oracle 到 MySQL最简单的方法
数据库迁移之从oracle 到 MySQL最简单的方法 因工作需要将oracle数据库换到MySQL数据库,数据量比较大,百万级别的数据,表也比较多,有没有一种既快捷又安全的方法呢?答案是肯定的,下面 ...
- Oracle中REGEXP_SUBSTR函数(字符串转多行)
Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...
- Oracle中REGEXP_SUBSTR函数
Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...
- Oracle的substr函数简单用法与substring区别
substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H' *从字符串第一个字符开始截取长度为1的字符串 subst ...
- Oracle中Table函数简单应用实例
说明 表函数可接受查询语句或游标作为输入参数,并可输出多行数据. 该函数可以平行执行,并可持续输出数据流,被称作管道式输出. 应用表函数可将数据转换分阶段处理,并省去中间结果的存储和缓冲表. 优势 1 ...
- Oracle的substr函数简单用法
substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H' *从字符串第一个字符开始截取长度为1的字符串 subst ...
- sort函数简单调用方法
向量调用sort函数排序,一般有三个参数,即为sort(v.begin(),v.end(),cmp),第三个传入的是比较函数的地址(函数名),决定你比较的性质,运用灵活 #include<ios ...
随机推荐
- [Visual Studio] 安装清单
VS安装位置要求路径必须是英文,且位于Program Files (x86)文件夹下. 下载工具vs_Professional.exe:https://pan.baidu.com/s/1jHRjiia ...
- 让机器教人学习更有效:Becoming the Expert - Interactive Multi-Class Machine Teaching
这是CVPR2015的一篇非常有趣的文章,论文研究了如何让机器自动地教导学生进行学习目标的分类.论文研发了一种机器学习方法,通过人机交互的过程中,不断的优化机器指导的方法和技巧,从而提高人学习目标分类 ...
- Git_操作标签
如果标签打错了,也可以删除: $ git tag -d v0.1 Deleted tag 'v0.1' (was e078af9) 因为创建的标签都只存储在本地,不会自动推送到远程.所以,打错的标签可 ...
- 【转】JABC访问oracle数据库报ORA-12505
Oracle 问题描述: 今天使用jdbc连接oracle 10.2.0.1.0 数据库的时候出现了下列错误: Connection refused(DESCRIPTION=(TMP=)(VSNNUM ...
- PowerDesigner导出图片
但是通过上面导出的图片会比较模糊不清晰,但是可以通过这样解决: 1.放大设计,然后全选复制全部 2.打开画图工具 3.粘贴到画图工具
- unity热更新
Unity3D 学习笔记4 —— UGUI+uLua游戏框架 C#Light 和 uLua的对比第二弹 在Unity中使用Lua脚本:语言层和游戏逻辑粘合层处理 Ulua_toLua_基本案例 Uni ...
- 精简高效CSS系列之二——浮动float
一.浮动基础知识 假如一个页面上有3个div块,如下排列: 图1:不使用浮动 图2:向右浮动 图2说明了框1脱离了文档流向右移动,直到它的右边缘碰到包含框的右边缘为止. 图3:向左浮动 图3说明了框1 ...
- java基础学习总结——接口
一.接口的概念 JAVA是只支持单继承的,但现实之中存在多重继承这种现象,如“金丝猴是一种动物”,金丝猴从动物这个类继承,同时“金丝猴是一种值钱的东西”,金丝猴从“值钱的东西”这个类继承,同时“金丝猴 ...
- js Date 函数方法
var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-???? ...
- OWIN and Katana
OWIN(Open Web Interface for .NET)是在.net的web server和web应用之间定义了一套规范. Katana是微软实现了OWIN的一个Web Server的项 ...