oracle - 如何在 oracle 中使用 Regexp_Replace 替换字符串
问题描述
我想替换这个:
"STORES/KOL#10/8/36#1718.00#4165570.00#119539388#PT3624496#9902001#04266#6721#PT3624496-11608091-1-55-STORES/KOL"
有了这个:
"STORES/KOL#10#8#36#1718.00#4165570.00#119539388#PT3624496#9902001#04266#6721#PT3624496-11608091-1-55-STORES/KOL"
基本上这是基于条件的替换,我想/
用#
类似的STORES/KOL
字符串替换,STORES/KOL
但10/8/36
字符串应该是10#8#36
解决方案
with s as (select '"STORES/KOL#10/8/36#1718.00#4165570.00#119539388#PT3624496#9902001#04266#6721#PT3624496-11608091-1-55-STORES/KOL"' str from dual)
select
replace(replace(str, '/', '#'), 'STORES#KOL', 'STORES/KOL') result_str_1,
regexp_replace(str, '(\d)/', '\1#') result_str_2
from s;
推荐阅读
- angular - 在reducer中获取后如何清除NgRx存储中的数据
- git - 如何从本地 windows 存储库推送到 windows git 远程服务器
- python - 如何使用类装饰器来实现单例模式?
- r - 根据另一列中的初始字符串添加列值
- nginx - nginx 在 MQTTS 上进行负载平衡
- python - Django如何创建仅对某些类型的用户可见的按钮
- capl - CAPL 代码从按钮发送信号值
- javascript - 即使添加了 async/await,代码也不会异步执行
- android - 如何在 Android 10 中以编程方式连接 Wi-Fi
- linux - 表示 SNMP 中的整数 26