【发布时间】:2019-01-01 14:27:37
【问题描述】:
在“示例”表中,我有一列“col1”,其中包含以下字符串
some example text here x2.0.3-a abc
some other example text 1.5 abc
another example text 0.1.4 mnp
some other example text abc
another example text mnp
现在我需要做一些事情
- 将
.之前的部分添加到另一列“col1” - 将
.部分添加到另一列“col2”
所以输出应该是这样的
col1 col2
some example text here x2.0.3-a
some other example text 1.5
another example text 0.1.4
some other example text
another example text
col1中字符串的一些属性是
- col1 中的字符串始终以
abc或mnp结尾 - 像
x2.0.3-a或0.1.4这样的数字是属性。这些属性可能并不总是存在于 col1 字符串中。但如果它退出,那么它总是存在于结束字符串abc或mnp之前。 - 在属性之前和属性之后总是有一个空格,即结束字符串 abc/mnp 和属性之间的另一个空格。
所以我的问题是如何分离属性并将它们添加到 col2 中?
我脑海中浮现的一个想法是尝试用*.* abc/mnp 或*.*.* abc/mnp 找到任何东西.anything. 空间abc/mnp 或任何东西.anything.anything 空间abc/mnp。我不确定我是否解释得当。
【问题讨论】:
-
您使用的是什么关系型数据库?数据库在正则表达式的作用上有所不同。
-
我正在使用 Oracle
-
能否详细说明col2的数据信息?除了您提供的模式之外,是否还有其他模式,例如 x3.1-a 或 version4.5?