select * from xfpj_xscjb;

- regexp_like的使用:查询含有中文的信息列表
select * from xfpj_xscjb where regexp_like(llcj,'[补考]');
select * from xfpj_xscjb where regexp_like(llcj,'[^0-9a-zA-Z]');

2.利用regexp_like:实现查询不含有中文的信息列表(正则没有实现)
select * from xfpj_xscjb where llcj not like '%补考%'(非正则实现)

3.regexp_count的用法
regexp_count:实现查找字符串出现匹配字符串的次数
select regexp_count(llcj,'补考') as cnt ,t.llcj from xfpj_xscjb t

regexp_count:实现查询不含有中文的信息列表(算是间接实现)
select a.* from (select regexp_count(llcj,'补考') as cnt ,t.* from xfpj_xscjb t) a where a.cnt='0'

regexp_count:对英文字母大小写敏感
select regexp_count (tjr,'a') as cnt ,t.tjr from xfpj_xscjb t

select regexp_count (tjr,'A') as cnt ,t.tjr from xfpj_xscjb t

regexp_count:去除对英文字母大小写敏感的方法启用参数i,第三个参数表示从第一个字符开始
select regexp_count (tjr,'a','1','i') as cnt ,t.tjr from xfpj_xscjb t

select regexp_count (tjr,'A','1','i') as cnt ,t.tjr from xfpj_xscjb t

regexp_replace的用法
regexp_replace实现将01234替换成abcd(数字和字母的长度相等)
select regexp_replace('0123456789','01234','abcd') as str from dual;

regexp_replace实现将01234和abcdef替换(数字和字母的长度不相等)
select regexp_replace('01234','01234','abcdef') as str from dual;

注意:1、利用regexp_like实现查询
除了含有(补考)以外的所有成绩列表还没有找到合适的方法,网上搜了一堆也没有一个实现的真不知道他们写的那些博客有毛用处,如果有用oracle正则实现的小伙伴可以给我留言 万分谢谢!!!
2.regexp_count使用时要注意对英文字符的大小写问题
本文主要介绍了Oracle中regexp_like、regexp_count和regexp_replace等正则函数的使用方法。包括利用regexp_like查询含中文或不含中文的信息列表,用regexp_count统计字符串匹配次数及处理大小写敏感问题,以及用regexp_replace进行字符串替换,还提及了未解决的查询需求。
3360

被折叠的 条评论
为什么被折叠?



