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 ...
随机推荐
- C#高级编程9-第4章 继承
继承是面向对象的一大特征.要深刻学习继承,需要学会使用调试的技巧来学习它,因为它比较抽象. 继承 继承是指一个具体的类型直接使用另一类型的某些数据成员或函数成员,继承的类是基类(父类),被继承的类是派 ...
- android 内部存储 安装apk
在做应用自动更新模块下载apk时遇到了内部存储和sd卡存储两种情况,存在sk卡中存储apk可以正常安装,可是在内部存储中安装apk时出现了parse error的问题. 在网上搜了搜,大致分为两种方案 ...
- TLC2262和TLC2264 轨对轨运算放大器
TLC2262和TLC2264分别是TI公司双路和四路运算放大器,两种器件可以在单电源或双电源条件下供电,从而增强了动态的范围,可以达到轨对轨输出的性能.TLC226X系列与TLC225X的微功耗和T ...
- 与Win8之磁盘活动时间100%斗争心得
Windows8因人而异地会在使用过程中磁盘活动时间无缘无故提升到100%并且可能出现持续性抽风现象,具体表现为0%瞬间飙升至100%后又回落,或者一直保持在100%导致使用过程卡顿,认真阅读本文有助 ...
- Spring使用环境变量控制配置文件加载(转)
项目中需要用到很多配置文件,不同环境的配置文件是不一样的,因此如果只用一个配置文件,势必会造成配置文件混乱,这里提供一种利用环境变量控制配置文件加载的方法,如下: 一.配置环境变量 如果是window ...
- arcgis andriod GeometryEngine使用
intersectionMenuItem.setChecked(true); showGeometry(GeometryEngine.intersection(inputPolygon1, input ...
- VC6 下 libpng 库的编译与初步使用
VC6 下 libpng 库的编译与初步使用 目录 libong 库的介绍 VC6 下 libpng 的编译 下载 libpng 与 zlib 进行编译 得到 .lib 文件 初步使用 对 VC6 ...
- etcd集群搭建
etcd介绍,以及适用场景,参考:http://www.infoq.com/cn/articles/etcd-interpretation-application-scenario-implement ...
- CRF 及CRF++ 安装与解释
CRF简介 Conditional Random Field:条件随机场,一种机器学习技术(模型) CRF由John Lafferty最早用于NLP技术领域,其在NLP技术领域中主要用于文本标注,并有 ...
- Python 基础学习 总结篇
Python 基础学习总结 先附上所有的章节: Python学习(一)安装.环境配置及IDE推荐 Python学习(二)Python 简介 Python学习(三)流程控制 Python学习(四)数据结 ...