Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Oracle sql中剪切字符串并返回子字符串_Sql_Regex_Oracle - Fatal编程技术网

如何在Oracle sql中剪切字符串并返回子字符串

如何在Oracle sql中剪切字符串并返回子字符串,sql,regex,oracle,Sql,Regex,Oracle,我在我的项目中有一个需求,我需要拆分url并从中提取变量,url是表中的一列。url看起来像这样 输入行 "http://example.com/wps/myportal/example/viewer?mstrContentType=Report& mstrId=15F4AC9C4453E5F75456438F732F7B8C&contentName=7.++CTI+Session+Order+Counts&proj=System+Xr+-+DMDR/CW&w

我在我的项目中有一个需求,我需要拆分url并从中提取变量,url是表中的一列。url看起来像这样

输入行

"http://example.com/wps/myportal/example/viewer?mstrContentType=Report&   mstrId=15F4AC9C4453E5F75456438F732F7B8C&contentName=7.++CTI+Session+Order+Counts&proj=System+Xr+-+DMDR/CW&workspaceName=&woId=&vendorId=Microstrategy"
我需要如下的o/p与如下的目标列进行比较

ContentType=Report
mstrId=15F4AC9C4453E5F75456438F732F7B8C
contentName=7.++CTI+Session+Order+Counts
etc...
我只能使用Oracle,不应该使用编程语言


谢谢。

如果您的url字符串遵循可预测的格式,您可以使用


这将返回
mstrContentType
参数的值-等号右侧但在下一个参数之前的子字符串。

这里您需要使用的是REGEXP\u SUBSTR,如下所示

create table test1(col1 varchar2(4000));
insert into test1 values(
'http://example.com/wps/myportal/example/viewer?mstrContentType=Report&   mstrId=15F4AC9C4453E5F75456438F732F7B8C&contentName=7.++CTI+Session+Order+Counts&proj=System+Xr+-+DMDR/CW&workspaceName=&woId=&vendorId=Microstrategy'
);

select regexp_substr(col1,'[^?"]+',1,2) ss from test1;

select trim(regexp_substr(regexp_substr(col1,'[^?"]+',1,2),'[^&]+', 1, level)) as output_data from test1
connect by regexp_substr(regexp_substr(col1,'[^?"]+',1,2), '[^&]+', 1, level) is not null;
输出数据

mstrContentType=Report
mstrId=15F4AC9C4453E5F75456438F732F7B8C
contentName=7.++CTI+Session+Order+Counts
proj=System+Xr+-+DMDR/CW
workspaceName=
woId=
vendorId=Microstrategy

您是否阅读过描述字符串函数的Oracle SQL文档?您尝试了什么?结果中的第一个预期字符串是
mstrContentType=Report
检查答案,我在下面提交了预期结果。如果有任何问题,请告诉我们。谢谢大家,基本上需要在=。例如,报告15F4AC9C4453E5F75456438F732F7B8C 7.++CTI+会话+订单+计数系统+Xr+-+DMDR/CW null null=microstategy如果信息有用,您可以接受我的回答。
mstrContentType=Report
mstrId=15F4AC9C4453E5F75456438F732F7B8C
contentName=7.++CTI+Session+Order+Counts
proj=System+Xr+-+DMDR/CW
workspaceName=
woId=
vendorId=Microstrategy