本文介绍了使用正则表达式分割复杂的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个字符串,我需要使用Oracle Regexp_substr
I have this string which i need to split using Oracle Regexp_substr
字符串就像
"123456","4,5,6","Hi This is "Sample" String",12345,022222
我需要将此字符串拆分为
I need to split this string as
"123456"
"4,5,6"
"Hi This is "Sample" String"
12345
022222
我尝试使用以下逻辑尝试使用",
作为分隔符,然后使用,
作为分隔符提取字符串,当我使用REGEXP_(string,'".*",',1,1)
时将bur提取出来,然后将字符串变成
I tried using the following logic Tried to extract string using ",
as delimiter followed by ,
as delimiter, bur when I use REGEXP_(string,'".*",',1,1)
then it turns the string into
"123456","4,5,6","Hi This is "Sample" String",
因为REGEXP是贪婪的表情.
since REGEXP are greedy expression.
我如何达到最终结果?
推荐答案
此示例适用于您的示例:
This one works for your examples:
(".+?"(?=,))|\w+
这篇关于使用正则表达式分割复杂的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!