show parameter background_dump_dest; 查看Oracle实例的警告日志
--查找两个字符-之间的字符串
select regexp_substr('123-456-789','-[^-]+') "REGEXP_SUBSTR" from dual;
--查询结果: -456
-- 搜索一个冒号
select regexp_substr('My leager: Debits, Credits, and Invoices 1940',':') from dual;
--从指定位置搜索,直到遇到下一个,
select regexp_substr('My leager: Debits, Credits, and Invoices 1940','[:punct][^,]+,') from dual;
--查询结果: : Debits
[:punct] 所有标点符号 [:digit:] 所有的数字 [:space:] 所有的空隔字符(不打印) [:blank:]
[:alnum:] 所有的字符和数字字符 [:alpha:] 所有的字符 [:lower:] 所有的小写字符
--regexp_substr(source_string,pattern[,position[,occurrence[,match_parameter]]]);
-- 从第一个字符开始,搜索第1次出现,不区分大小写
select regexp_substr('My leager: Debits, Credits, and Invoices 1940','my',1,1,'i') from dual;
--查询结果: : My
--regexp_instr(source_string,pattern[,position[,occurrence[,return_option[,match_parameter]]]]);
--返回从第一个位置开始出现的第一个字符的位置的下一位
select regexp_instr('My leager: Debits, Credits, and Invoices 1940','[[digit:]]',1,1,1) from dual;
--regexp_like(source_string,pattern[,match_parameter])
--查询电话号码以415开头的名字
select lastname from address where regexp_like(Phone,'415+');
--replace(char,search_string[,replace_string])
--计算源串删除搜索串以后的长度
select length(replace('GEORGE','GE',NULL)) from dual;
--查询结果: 2
--regexp_replace(source_string,pattern[,replace_string[,position][,occurcence[,match_parameter]]])
select regexp_replace(phone,'([[:digit:]]{3})-([[:digit:]]{3})-([[:digit:]]{4})') from address;
--123-456-7890 查询结果: 123-456-7890
select regexp_replace(phone,'([[:digit:]]{3})-([[:digit:]]{3})-([[:digit:]]{4})','(\1) \2-\3') from address;
--123-456-7890 查询结果: (123) 456-7890
--将第一个5替换成.
select regexp_replace(phone,'5','.',1,1) from address;
--123-456-7890 查询结果: 123-4.6-7890
--搜索GE出现的次数
select regexp_count('GEORGE','GE',1,'i') from dual;
--2