Oracle 中使用正则表达式
2024-10-06 23:47:37
Oracle使用正则表达式离不开这4个函数:
1。regexp_like
select t3.cert_no from table_name t3 where regexp_like(t3.cert_no, '^(\d{15}|\d{18})$')
2。regexp_substr
SELECT REGEXP_SUBSTR('first field, second field , third field', ', [^,]*,') FROM dual
3。regexp_instr
SELECT REGEXP_INSTR ('hello itmyhome', 'e') FROM dual;
4。regexp_replace
select regexp_replace('','','abc') from dual;
拓展
1,通过证件号码获取生日
select to_date(substr('',7,8),'yyyyMMdd') from dual;
2,通过证件号码获取年龄
select trunc((to_char(sysdate, 'yyyyMMdd') -
to_char(to_date(substr('', 7, 8),
'yyyy-MM-dd'),
'yyyyMMdd')) / 10000)
from dual;
3,通过证件号码获取年龄不满16周岁的生日(ps:证件号码为15位或者18位,今年为2019年16岁出生于20030101)
select to_date(substr(t.cert_no, 7, 8), 'yyyyMMdd')
from table_name t
where to_date((case when length(t.cert_no) = 18 then
substr(t.cert_no, 7, 8) when length(t.cert_no) = 15 then
'' || substr(t.cert_no, 7, 6) end),
'yyyyMMdd') < to_date('', 'yyyyMMdd')
最新文章
- C# upnp
- ASP.NET MVC中分析淘宝网页发生乱码标题搞定方法
- 今天再分享一个TextView内容风格化的类
- .NET基础拾遗(7)多线程开发基础4
- 修改host文件的P处理
- VS2008下OpenCV1.0的设置
- Lazy.js : 让 JavaScript 变懒
- php实现批量修改文件名称
- Java字符串格式化记录
- matplotlib图例-【老鱼学matplotlib】
- nvwgf2umx.dll 显卡崩溃问题尝试修复
- liunx学习笔记
- Xamarin Essentials教程安全存储SecureStorage
- tomcat8 tomcat-users相关配置
- 百度地图api公交路线,IE下跳转百度地图后中文变成乱码的解决办法
- ueditor编辑器视频上传不能预览的问题
- MFC函数—SetRegistryKey
- 面向对象的JavaScript --- 动态类型语言
- 网络与多线程---OC中多线程使用方法(一)
- PCL点云变换与移除NaN