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#中实现视频播放器
当我们需要在C#中实现视频播放器的时候,可以使用如下几种方法: 一.使用MediaPlayer ActiveX控件 在C#中支持视屏播放器最简单的方式就是插入MediaPlayer控件了,在WPF中还 ...
- android应用名称设置的问题
<application android:label="@string/app_name1" <activity and ...
- CHM编写软件
工具选择 1. HTML编辑工具:就是用什么软件写文档的问题.一直都是做.NET开发,所以选择HTML编辑也大都在MS阵营里选.主要有以下几种HTML编辑器. (1) Dr ...
- .NET:CLR via C#:Runtime Serialization
Making a Type Serializable The SerializableAttribute custom attribute may be applied to reference ty ...
- Android之多媒体扫描过程
转自:http://blog.csdn.net/yan8024/article/details/6620359下面是系统图 MediaScannerReceiver会在任何的ACTION_B ...
- Java IO 体系结构
参考文章地址: http://blog.csdn.net/oracle_microsoft/article/details/2634231 Java IO体系结构看似庞大复杂,其实有规律可循,要弄清楚 ...
- poj 3041 Asteroids 题解
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20686 Accepted: 11239 Descr ...
- cocos2d js ScrollView的使用方法
游戏中非常多须要用到ScrollView的情况,也就是须要滚动一片区域. 这里有两种实现方法,一种是使用cocos studio的方式,另外一种是手写代码.先看第一种 第一种记得在设置滚动区域时选取裁 ...
- Informatica 常用组件Lookup之五 转换属性
查找转换的属性标识数据库源.PowerCenter 如何处理转换,以及它如何处理高速缓存和多项匹配. 创建映射时,为每个查找转换指定属性.创建会话时,您可在会话属性中覆盖某些属性,如每个转换的索引和数 ...
- HDU1226:超级密码(BFS)
Problem Description Ignatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息: 密码是一个C进 ...