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函数简单使用方法的更多相关文章

  1. Oracle的REGEXP_INSTR函数简单使用方法

    REGEXP_INSTR函数让你搜索一个正則表達式模式字符串. 函数使用输入字符集定义的字符进行字符串的计算. 它返回一个整数,指示開始或结束匹配的子位置.这取决于return_option參数的值. ...

  2. Oracle中REGEXP_SUBSTR函数(转)

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下:在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20','2 ...

  3. 数据库迁移之从oracle 到 MySQL最简单的方法

    数据库迁移之从oracle 到 MySQL最简单的方法 因工作需要将oracle数据库换到MySQL数据库,数据量比较大,百万级别的数据,表也比较多,有没有一种既快捷又安全的方法呢?答案是肯定的,下面 ...

  4. Oracle中REGEXP_SUBSTR函数(字符串转多行)

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...

  5. Oracle中REGEXP_SUBSTR函数

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...

  6. Oracle的substr函数简单用法与substring区别

    substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H'  *从字符串第一个字符开始截取长度为1的字符串 subst ...

  7. Oracle中Table函数简单应用实例

    说明 表函数可接受查询语句或游标作为输入参数,并可输出多行数据. 该函数可以平行执行,并可持续输出数据流,被称作管道式输出. 应用表函数可将数据转换分阶段处理,并省去中间结果的存储和缓冲表. 优势 1 ...

  8. Oracle的substr函数简单用法

    substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H'  *从字符串第一个字符开始截取长度为1的字符串 subst ...

  9. sort函数简单调用方法

    向量调用sort函数排序,一般有三个参数,即为sort(v.begin(),v.end(),cmp),第三个传入的是比较函数的地址(函数名),决定你比较的性质,运用灵活 #include<ios ...

随机推荐

  1. Nginx学习之一-惊群现象

    惊群问题(thundering herd)的产生 在建立连接的时候,Nginx处于充分发挥多核CPU架构性能的考虑,使用了多个worker子进程监听相同端口的设计,这样多个子进程在accept建立新连 ...

  2. 如何使用mysql存储树形关系

    最近遇到业务的一个类似文件系统的存储需求,对于如何在mysql中存储一颗树进行了一些讨论,分享一下,看看有没有更优的解决方案. 一.现有情况 首先,先假设有这么一颗树,一共9个节点,1是root节点, ...

  3. angularjs中如何在异步请求执行完以后再执行其他函数?

    angularjs中如何在异步请求执行完以后再执行其他函数? 之前脑袋回路就是从上到下的执行js,直到有一次我的页面上已经显示了空才走到angularjs里的$http的成功回调函数里,然后才开始正视 ...

  4. MyBatis连接SQL Server的关键点

    一.Maven包配置 <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc --> < ...

  5. druid数据源

    Druid是一个JDBC组件,它包括三部分:  DruidDriver 代理Driver,能够提供基于Filter-Chain模式的插件体系. DruidDataSource 高效可管理的数据库连接池 ...

  6. Linux shell命令中expr

    在Linux shell命令中expr虽然不是很起眼,但是它的作用是非常大的!到目前为止,我个人看来最大的作用就是两个——四则运算和字符串的操作. 先说四则运算,在Shell中四则运算不能简简单单的加 ...

  7. jquery googleapis

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type=&quo ...

  8. Inside Portable Class Libraries

    Portable Class Libraries were introduced with Visual Studio 2010 SP1 to aid writing libraries that c ...

  9. java zxing实现二维码生成和解析zxing实现二维码生成和解析

    原文:https://www.cnblogs.com/zhangzhen894095789/p/6623041.html zxing实现二维码生成和解析   二维码 zxing   二维码的生成与解析 ...

  10. 找回 : MobileCoreServices.framework

    MobileCoreServices.framework   丢失后,可通过如下方式找回: 1.在同事机器上拷贝一个. 路径: 2.重装一个xcode 实践:将xcode4.5下的文件拷到xcode4 ...