用正则表达式拆分字符串test =“tets”

时间:2021-09-25 21:38:10

I am trying to split the following string in sql:

我试图在sql中拆分以下字符串:

select regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','[^" ]+', 1, level) 
from dual
connect by regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','[^" ]+', 1, level) is not null;

but it is splitting by space. I need a return like version="100104 name="Contracts Ref." can someone guide me?

但它是按空间分裂的。我需要一个像版本=“100104 name =”Contracts Ref。的回报。“有人可以指导我吗?

1 个解决方案

#1


0  

I believe you need something like this:

我相信你需要这样的东西:

select regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','(\w+=\"[^\"]*\")', 1, level) 
from dual
connect by regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','(\w+=\"[^\"]*\")', 1, level) is not null;

In the new regex pattern (\w+=\"[^\"]*\") -

在新的正则表达式模式中(\ w + = \“[^ \”] * \“) -

\w+=\" Finds 1 or more occurrences of a letter or number, followed by ="

\ w + = \“查找一个或多个字母或数字,后跟=”

[^\"] Finds everything after the first quote that isn't a quote itself

[^ \“]在第一个引用之后查找不是引用本身的所有内容

\" Finally we get the last quote.

“最后我们得到了最后一句话。

#1


0  

I believe you need something like this:

我相信你需要这样的东西:

select regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','(\w+=\"[^\"]*\")', 1, level) 
from dual
connect by regexp_substr('version="100104" name="Contracts Ref." desc="" type="picker" bp_name="Contracts"','(\w+=\"[^\"]*\")', 1, level) is not null;

In the new regex pattern (\w+=\"[^\"]*\") -

在新的正则表达式模式中(\ w + = \“[^ \”] * \“) -

\w+=\" Finds 1 or more occurrences of a letter or number, followed by ="

\ w + = \“查找一个或多个字母或数字,后跟=”

[^\"] Finds everything after the first quote that isn't a quote itself

[^ \“]在第一个引用之后查找不是引用本身的所有内容

\" Finally we get the last quote.

“最后我们得到了最后一句话。