PLSQL replace and regexp_replace
来源:互联网 发布:音乐手游 知乎 编辑:程序博客网 时间:2024/06/08 18:17
语法:
Replace(Source String, Search String, Replace String)
RegExp_replace(Source String, Pattern, Replace String, position, occurrence, match_parameter);
Replace 用于普通替换某个字符(串)
RegExp_replace 可以用于正则匹配
可选参数为: position, occurrence, match_parameter
position为从第几个开始匹配,默认为1,从第一个开始匹配
occurrence 为0,则替换全部,默认为0. 为其他正整数n,则替换匹配到的第n个
match_parameter:i 大小写不敏感
c 大小写不敏感
n 点“ . ” 可以匹配换行符
m 多行匹配
x 忽略空白,默认是匹配空白符的
测试例子:
set define off;
set serveroutput on;declare
test_str varchar2(32767);
dest_str varchar2(32767);
dest_str_reg varchar2(32767);
begin
test_str := 'I am a string for test. ';
dbms_output.put_line('>>>>>>>test_str::'||test_str||'!');
dest_str := REPLACE (TRIM (test_str ), '\s', '%');
dbms_output.put_line('>>>>>>>dest_str::'||dest_str||'!');
dest_str_reg := regexp_REPLACE (TRIM (test_str ), '\s', '%');
dbms_output.put_line('>>>>>>>dest_str_reg::'||dest_str_reg||'!');
end;
/
Result:
>>>>>>>test_str::I am a string for test. !
>>>>>>>dest_str::I am a string for test.!
>>>>>>>dest_str::I am a s*ring for *es*.!
>>>>>>>dest_str_reg::I%am%a%string%for%test.!
Oracle doc:
Replace: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions134.htm#i78608
RegExp_Replace: https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions130.htm
- PLSQL replace and regexp_replace
- REPLACE 和REGEXP_REPLACE
- 替换replace,translate,rtrim,regexp_replace
- ORACLE 学习REGEXP_replace,translate,replace使用
- oracle 之replace 和 regexp_replace函数
- REGEXP_REPLACE
- Oracle/PLSQL: Replace Function
- UltraEdit search and replace
- vim find and replace
- Search and replace string
- Bonfire: Search and Replace
- freecodecamp Search and Replace
- Search and replace
- Search and Replace
- Search and Replace
- Search and Replace
- Perl Regex: replace and assign
- Difference between replace and translate
- DataBase学习笔记 --- SQL实现如果存在表,则删除
- 负载均衡详解
- uboot杂记-logo显示和fastboot原理等
- 小白都能理解的数据分析和大数据(一)
- [bigdata-015] apache nifi 官方文档摘要
- PLSQL replace and regexp_replace
- 随着Cyanogen的死亡,Google对Android的控制比任何时候更严密
- terracotta3.7.7+apche2.2+tomcat6集群配置
- R-CNN
- HTML
- 事件对象event
- guava之Multimap
- 跑maven慢的问题/加快mave下载速度
- 个人记录-LeetCode 59. Spiral Matrix II