oracle regexp_replace 正则表达式的使用

Oracle 正则表达式详解(regexp_substr、regexp_instr、regexp_replace、regexp_like、regexp_count) 文章目录1 概述2 匹配规则3 正则函数3.1 regexp_substr()3.2 regexp_instr()3.3 regexp_replace()3.4 regexp_like() 1 概述 1. 作用:处理字符时,很强大 2. 分类:与下列相似,当功能更加强大('支持正则表达式') (1) regexp_like : 同 like 功能相似(模糊 '匹配') (2) regexp_instr : 同 instr 功能相似(返回字符所在 '下标') (3) regexp_s 阅读详情

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions130.htm

REGEXP_REPLACE

Syntax

Description of regexp_replace.gif follows
Description of the illustration regexp_replace.gif

Purpose

REGEXP_REPLACE extends the functionality of the REPLACE function by letting you search a string for a regular expression pattern. By default, the function returns source_char with every occurrence of the regular expression pattern replaced with replace_string. The string returned is in the same character set as source_char. The function returns VARCHAR2 if the first argument is not a LOB and returns CLOB if the first argument is a LOB.

This function complies with the POSIX regular expression standard and the Unicode Regular Expression Guidelines. For more information, please refer to Appendix C, "Oracle Regular Expression Support".

  • source_char is a character expression that serves as the search value. It is commonly a character column and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB or NCLOB.

  • pattern is the regular expression. It is usually a text literal and can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. It can contain up to 512 bytes. If the datatype of pattern is different from the datatype of source_char, Oracle Database converts pattern to the datatype of source_char. For a listing of the operators you can specify in pattern, please refer to Appendix C, "Oracle Regular Expression Support".

  • replace_string can be of any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. If replace_string is a CLOB or NCLOB, then Oracle truncates replace_string to 32K. The replace_string can contain up to 500 backreferences to subexpressions in the form \n, where n is a number from 1 to 9. If n is the backslash character in replace_string, then you must precede it with the escape character (\\). For more information on backreference expressions, please refer to the notes to "Oracle Regular Expression Support", Table C-1.

  • position is a positive integer indicating the character of source_char where Oracle should begin the search. The default is 1, meaning that Oracle begins the search at the first character of source_char.

  • occurrence is a nonnegative integer indicating the occurrence of the replace operation:

    • If you specify 0, then Oracle replaces all occurrences of the match.

    • If you specify a positive integer n, then Oracle replaces the nth occurrence.

  • match_parameter is a text literal that lets you change the default matching behavior of the function. This argument affects only the matching process and has no effect on replace_string. You can specify one or more of the following values for match_parameter:

    • 'i' specifies case-insensitive matching.

    • 'c' specifies case-sensitive matching.

    • 'n' allows the period (.), which is the match-any-character character, to match the newline character. If you omit this parameter, the period does not match the newline character.

    • 'm' treats the source string as multiple lines. Oracle interprets ^ and $ as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, Oracle treats the source string as a single line.

    • 'x' ignores whitespace characters. By default, whitespace characters match themselves.

    If you specify multiple contradictory values, Oracle uses the last value. For example, if you specify 'ic', then Oracle uses case-sensitive matching. If you specify a character other than those shown above, then Oracle returns an error.

    If you omit match_parameter, then:

    • The default case sensitivity is determined by the value of the NLS_SORT parameter.

    • A period (.) does not match the newline character.

    • The source string is treated as a single line.

      See Also:

      • REPLACE

      • REGEXP_INSTR, REGEXP_SUBSTR, and REGEXP_LIKE Condition


        ------转发例子

        全部测试数据

        SQL> select * from test_reg_substr;

        A

        -----------------------------------

        ABC123XYZ

        ABC123XYZ456

        <Name>Edward</Name>

         

        替换数字

        SQL> SELECT

         2    REGEXP_REPLACE (a,'[0-9]+','QQQ')  AS A

         3  FROM

         4    test_reg_substr;

        A

        -----------------------------------------------

        ABCQQQXYZ

        ABCQQQXYZQQQ

        <Name>Edward</Name> 

         

        替换数字(从第一个字母开始匹配,替换第1个匹配项目)

        SQL> SELECT

         2    REGEXP_REPLACE (a,'[0-9]+','QQQ', 1, 1)  AS A

         3  FROM

         4    test_reg_substr;

        A

        ------------------------------------------------------

        ABCQQQXYZ

        ABCQQQXYZ456

        <Name>Edward</Name>

         

        替换数字(从第一个字母开始匹配,替换第2个匹配项目)

        SQL> SELECT

         2    REGEXP_REPLACE (a,'[0-9]+','Q', 1, 2)  AS A

         3  FROM

         4    test_reg_substr;

        A

        ---------------------------------------------------

        ABC123XYZ

        ABC123XYZQ

        <Name>Edward</Name>

         

        替换第二个单词

        SQL> SELECT

         2    REGEXP_REPLACE (a,'\w+','Kimi', 1, 2)  AS A

         3  FROM

         4    test_reg_substr;

        A

        ---------------------------------------------------

        ABC123XYZ

        ABC123XYZ456

        <Name>Kimi</Name>


        替换掉大写字母,小写字母,数字 0-9  为空

          select  regexp_replace(regexp_replace(regexp_replace(string_In,'[A-Z]',''),'[0-9]',''),'[a-z]','')
          INTO V_RETURN from dual





Oracle 正则表达式详解(regexp_substr、regexp_instr、regexp_replace、regexp_like) 文章目录 1 概述2 匹配规则3 正则函数3.1 regexp_substr()3.2 regexp_instr()3.3 regexp_replace()3.4 regexp_like() 1 概述 1. 作用:处理字符时,很强大 2. 分类:与下列相似,但功能更加强大(‘支持正则表达式’) (1) regexp_like : 同 like 功能相似(模糊 ‘匹配’) (2) regexp_instr : 同 instr 功能相似(返回字符所在 ‘下标’) (3) regexp_s.. 阅读详情

相关推荐

【代码】获取高级行情数据,并通过 qmt 进行实际下单交易,自动实现止盈止损管理

【代码】获取高级行情数据,并通过 qmt 进行实际下单交易,自动实现止盈止损管理

XD1996CD的博客 4116

oracle中replace函数

当你使用 REGEXP_REPLACE 函数或其他正则表达式相关函数时,你可以在 replacement 参数中使用 \1, \2, \3, 等来引用在模式中定义的捕获组。这允许你在替换操作中使用正则表达式捕获组的内容。在这个示例中,\1, \2, 和 \3 分别引用正则表达式中的第一个、第二个和第三个捕获组,从而将日期格式替换为 “yyyy/mm/dd” 形式。例如,如果你的正则表达式模式中有一个捕获组 (pattern),你可以在 replacement 中使用 \1 来引用该捕获组的内容。

Edwardyd的博客 2077

android广告SDK原理详解(附源码)

广大的开发者吃糠咽菜开发了一两款APP,获取了一些流量后自然就会想到流量变现,一般情况下大家会选择到百度联盟或者Google Admob这些广告服务提供商注册开发者账号,在自己的APP里面加上几行广告位代码,集成他们的广告SDK包。然后谋事在人,成事在天,只有每天看报表查查收益。   也有一些开发者为了能够提高自己的变现水平,同时接入了好几家的sdk,哪家出的收益高一点我就出哪家的广告,但是这

rmcgogo的博客 1万+

Oracle数据库SQL参考——REGEXP_REPLACE正则替换

Oracle数据库SQL参考——REGEXP_REPLACE正则替换REGEXP_REPLACE句法目的示例 REGEXP_REPLACE句法 目的 https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions130.htm regexp_replace函数是replace函数的扩展函数,用于通过正则表达式来进行匹配替换,默认情...

qq_44813644的博客 5127

国资e学快速学习实战教程

本文主要介绍了国资e学快速学习实战教程,希望能对同学们有所帮助。 文章目录 1. 前言 2. 实战教程

weixin_43178406的博客 11万+

Android SELinux——neverallow问题处理(十六)

遇到 neverallow 规则问题,千万别急着去注释/剔除里面原有的规则(原生的尽量别动)。增加 allow 规则是常见的解决办法,但是随着 android 版本的升级,系统对 SELinux 的管控越来越严,增加了大量的 neverallow。一般情况下,向默认标签授予权限的做法是错误的,其中许多权限都是 neverallow 规则所不允许的。按照上面方法去添加 SELinux 可能会违反了 neverallow 规则,编译时候会报 neverallow 相关的错误。

小旭的专栏 2694

REGEXP_REPLACE的使用方法

regexp_replace的使用非常灵活,且容易忘记,故做此笔记。 没有过多的介绍使用说明,只是根据个人理解列出很多相似案例,个人觉得通过对比,更容易理解其使用技巧。 命令格式: regexp_replace(source, pattern, replace_string, occurrence) 参数说明: ● source: string类型,要替换的原始字符串。 ● pattern: string类型常量,要匹配的正则模式,pattern为空串时抛异常。 ● replace_string:.

JohnnyChu的博客 10万+

深度学习100例-卷积神经网络(CNN)彩色图片分类 | 第2天

文章目录前期工作设置GPU导入数据标准化可视化构建CNN网络编译训练模型预测模型评估 前期工作 设置GPU 如果使用的是CPU可以忽略这步 import tensorflow as tf gpus = tf.config.list_physical_devices("GPU") if gpus: gpu0 = gpus[0] #如果有多个GPU,仅使用第0个GPU tf.config.experimental.set_memory_growth(gpu0, True) #设置GPU显存用量

“365天深度学习训练营”报名进行中~ 7856

Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace

Oracle使用正则表达式4个主要函数: 1、regexp_like 只能用于条件表达式,和 like 类似,但是使用的正则表达式进行匹配,语法很简单: 2、regexp_substr 函数,和 substr 类似,用于拾取合符正则表达式描述的字符子串,语法如下: 3、regexp_instr 函数,和 instr 类似,用于标定符合正则表达式的字符子串的开始位置,语法如下...

diaorong5437的博客 394

密码学系列3-Elgamal加密及其IND-CPA安全性证明

但这没有任何影响,敌手本身就只能知道公钥,他并没有能力知道挑战者是否知道对应的私钥。所以上述整个游戏就是一个模拟实验,敌手无法区分挑战者运行的是这个模拟实验,还是真正的按照第一节的算法构造的实验(挑战者知道私钥…为什么合起来的时候有1/2:因为T既可能是随机的也可能是g^{ab},这两种情况概率为1/2。能够攻破Elgamal加密方案,那么挑战者利用敌手的能力构建下面游戏,来求解困难性问题DDH。就是挑战者选的随机数,虽然挑战者自己也不知道。),否则挑战者输出0,作为DDH的回答。

qq_41359358的博客 1252

华为OD机试真题 新系统2026-04-15 Python&JS 实现【失灵的键盘】

有一个键盘有2个按键失灵了,按下这些键时会连续输出其他键对应的字符两次。具体如下: 1. 按下j键一次,屏幕上显示uu(两个连续的u);  按下b键一次,屏幕上显示t(两个连续的t) 2. u键和t键是好的,按下u键一次时,屏幕只会显示一次u(正常按键);按下t键一次时,屏幕只会显示一次t(正常按键) 3. 假定屏幕上连续显示两个t一定是按了一次b键,而不是两次t键;假定按键t之后不会紧接着按键b,即tttt转义为两个b,而不可能是tb

MISAYAONE的博客 526

Oracle 正则表达式函数-REGEXP_REPLACE 使用例子

REGEXP_REPLACE 6个参数 第一个是输入的字符串 第二个是正则表达式 第三个是替换的字符 第四个是标识从第几个字符开始正则表达式匹配。(默认为1) 第五个是标识第几个匹配组。(默认为全部都替换掉) 第六个是是取值范围: i:大小写不敏感; c:大小写敏感; n:点号 . 不匹配换行符号; m:多行模式; x:扩展模式,忽略正则表达式中的空白字符。 全部测试数据 SQL> sele...

枯萎花一朵 1285

手把手教你学Simulink——整流器场景:基于PWM控制的单相全桥整流器设计

摘要:本文详细介绍了使用Simulink搭建基于PWM控制的单相全桥整流器的完整设计流程。主要内容包括:系统结构设计(含交流电源、全桥整流器、滤波电路等模块)、分步骤建模过程(从创建项目到添加各功能模块)、双闭环控制系统设计(电压外环和电流内环PI控制)、参数设置建议及仿真分析。通过仿真验证,该整流器可实现单位功率因数运行和稳定输出电压,并提供了数字锁相环等优化方向。文章为电力电子系统设计提供了实用的Simulink建模指导。(149字)

MHD0815的博客 325

oracle剔除regexplike,Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace...

Oracle使用正则表达式离不开这4个函数:1。regexp_like2。regexp_substr3。regexp_instr4。regexp_replace看函数名称大概就能猜到有什么用了。regexp_like 只能用于条件表达式,和 like 类似,但是使用的正则表达式进行匹配,语法很简单:regexp_substr 函数,和 substr 类似,用于拾取合符正则表达式描述的字符子串,语法...

weixin_42298646的博客 842

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Oracle正则表达式函数regexp_like、regexp_substr、regexp_instr、regexp_replace

正则表达式在Oracle10g中的应用--REGEXP_INSTR函数   regexp_like 只能用于条件表达式,和 like 类似,但是使用的正则表达式进行匹配     regexp_substr 函数,和 substr 类似,用于拾取合符正则表达式描述的字符子串    regexp_instr 函数,和 instr 类似,用于标定符合正则表达式的字符子串的开始位置

2139

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Oracle正则表达式之 Regexp_substr,Regexp_instr,Regexp_replace,Regexp_like

Oracle正则表达式使用介绍 正则表达式具有强大、便捷、高效的文本处理功能。能够添加、删除、分析、叠加、插入和修整各种类型的文本和数据。Oracle从10g开始支持正则表达式 下面通过一些例子来说明使用正则表达式来处理一些工作中常见的问题。 1. REGEXP_SUBSTR REGEXP_SUBSTR 函数使用正则表达式来指定返回串的起点和终点,返回与source_s...

weixin_30730151的博客 965

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Oracle正则表达式函数:regexp_like、regexp_substr、regexp_instr、regexp_replace

  /*   ORACLE中的支持正则表达式的函数主要有下面四个:   1,REGEXP_LIKE :与LIKE的功能相似   2,REGEXP_INSTR :与INSTR的功能相似   3,REGEXP_SUBSTR :与SUBSTR的功能相似   4,REGEXP_REPLACE :与REPLACE的功能相似   它们在用法上与Oracle SQL 函数LIKE、INSTR、SU...

bz442bz 251
上一篇: java项目导入
下一篇: 转载 NovaMind思维导图详细使用教程
AddisonJ
博客等级 码龄16年 45粉丝 50原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值