regexp_replace函数和regexp_substr函数

regexp_replace函数和regexp_substr函数:


regexp_replace函数和regexp_substr函数的功能类似与字符函数replace和substr,只是这里的应用更加灵活,可以一下子匹配一系列的结果,而原来的函数只能一下子匹配一个固定的字符换。

1.regexp_replace的意义是: 找到给定模式匹配的字符串并用其他的字符串来替代。

语法:

regexp_replace(x,pattern[,replace_string[,start[,occurence[match_option]]]])

每个参数的意思分别是:

  x               待匹配的字符串
  pattern         正则表达式元字符构成的匹配模式
  replace_string  替换字符串
  start           开始位置
  occurence      匹配次数
  match_option   匹配参数

举例如下:

 select regexp_replace('hello everybody,may I have your attention please?',
                        'b[[:alpha:]]{3}',
                        'one')
    from dual;

将会返回结果:

hello everyone,may I have your attention please?

2.regexp_substr函数的意义: 找出与给定模式匹配的字符串并返回,

语法:

regexp_substr(x,pattern[,start[,occurence[match_option]]])
//这里各参数的意义与前面的函数regexp_replace的含义是一样做的。

举例如下:

select regexp_substr('I love oracle very much', 'o[[:alpha:]]{5}')
from dual;

将会返回结果:

   oracle
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值