当前位置:Gxlcms > 数据库问题 > Oracle正则表达式之匹配网址

Oracle正则表达式之匹配网址

时间:2021-07-01 10:21:17 帮助过:10人阅读

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

--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

Oracle正则表达式之匹配网址

标签:bsp   into   das   --   select   reg   values   int   insert   

人气教程排行