星空思维

导航

Oracle正则表达式之匹配网址

利于正则表达式匹配出网址

--1 表准备
create table test_regexp
(
object varchar2(50)
);

--2 数据准备

insert into test_regexp (OBJECT)
values ('http://www.baidu.com');

insert into test_regexp (OBJECT)
values ('http://360.cn');

insert into test_regexp (OBJECT)
values ('https://help.alipay.com');

insert into test_regexp (OBJECT)
values ('cctv.cn');

insert into test_regexp (OBJECT)
values ('www.cntv.com');

insert into test_regexp (OBJECT)
values ('23212.sasdas.2222');

commit;

--3 

select * from test_regexp where   regexp_like(object,'^(https?://)?(\w+\.)+[a-zA-Z]+$') ;

--4 返回结果

http://www.baidu.com
http://360.cn
https://help.alipay.com
cctv.cn
www.cntv.com
23212.sasdas.2222

posted on 2017-05-06 21:40  星空思维  阅读(182)  评论(0编辑  收藏  举报