regexp_substr函数的一般语法为
REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)
String为要判断的字符串
pattern是正则表达式
position要判断的起始位置
occurrence标示第几次出现
modifier匹配的模式('i'不区分大小写进行检索;'c'区分大小写进行检索)
比如使用正则表达式将'slot=63;subslot=2;port=8;vlanid=79;vlanid2=411;'拆分为5个字段
with test as(
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=411;' t from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=412;' from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=413;' from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=414;'from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=415;' from dual
)
select regexp_substr(t, '=([^=;]+);', 1, 1, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 2, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 3, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 4, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 5, 'i', 1) from test
疑问:为什么出现了第六个参数?同时第二个参数的开始的=和结束的+是什么意思?
REGEXP_SUBSTR(String, pattern, position, occurrence, modifier)
String为要判断的字符串
pattern是正则表达式
position要判断的起始位置
occurrence标示第几次出现
modifier匹配的模式('i'不区分大小写进行检索;'c'区分大小写进行检索)
比如使用正则表达式将'slot=63;subslot=2;port=8;vlanid=79;vlanid2=411;'拆分为5个字段
with test as(
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=411;' t from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=412;' from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=413;' from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=414;'from dual
union
select 'slot=63;subslot=2;port=8;vlanid=79;vlanid2=415;' from dual
)
select regexp_substr(t, '=([^=;]+);', 1, 1, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 2, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 3, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 4, 'i', 1),
regexp_substr(t, '=([^=;]+);', 1, 5, 'i', 1) from test
疑问:为什么出现了第六个参数?同时第二个参数的开始的=和结束的+是什么意思?
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28803801/viewspace-775641/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28803801/viewspace-775641/