[导读]Oracle使用正则表达式离不开这4个函数:
Oracle使用正则表达式离不开这4个函数:
1。regexp_like
2。regexp_substr
-- select regexp_substr('aaa,bb,ccccc,ddd,vvv','[^,]+',1,4) from dual
3。regexp_instr
4。regexp_replace
参数
1。source_char,输入的字符串,可以是列名或者字符串常量、变量。
2。pattern,正则表达式。
3。match_parameter,匹配选项。
取值范围: i:大小写不敏感; c:大小写敏感;n:点号 . 不匹配换行符号;m:多行模式;x:扩展模式,忽略正则表达式中的空白字符。
4。position,标识从第几个字符开始正则表达式匹配。
5。occurrence,标识第几个匹配组。
6。replace_string,替换的字符串。
例:
select str from tmp where id='like' and regexp_like(str,'A\d+','i'); -- 'i' 忽略大小写
regexp_substr(str,'[^,]+')
regexp_instr('192.168.0.1','\d',1,level) ind -- 每个数字的位置
regexp_replace(str,'020','GZ') str,