-
oracle正则表达式匹配日期
- YYYY-MM-DD
- YYYY/MM/DD
- YYYY.MM.DD
1900-2999日期正则表达式
select case
when regexp_like('2999-11-30',
'^((((19|2\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})-(0?[469]|11)-(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))-0?2-(0?[1-9]|[12]\d)))$') then
1
else
0
end
from dual;
select case
when regexp_like('2999/11/30',
'^((((19|2\d)\d{2})/(0?[13578]|1[02])/(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})/(0?[469]|11)/(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})/0?2/(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))/0?2/(0?[1-9]|[12]\d)))$') then
1
else
0
end
from dual;
select case
when regexp_like('2012.02.29',
'^((((19|2\d)\d{2})\.(0?[13578]|1[02])\.(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})\.(0?[469]|11)\.(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})\.0?2\.(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))\.0?2\.(0?[1-9]|[12]\d)))$') then
1
else
0
end
from dual;