【发布时间】:2016-12-26 18:24:02
【问题描述】:
我在一列中有如下数据
+----------------------+
| my_column |
+----------------------+
| test_PC_xyz_blah |
| test_PC_pqrs_bloh |
| test_Mobile_pqrs_bleh|
+----------------------+
如何将以下内容提取为列?
+----------+-------+
| Platform | Value |
+----------+-------+
| PC | xyz |
| PC | pqrs |
| Mobile | pqrs |
+----------+-------+
我尝试使用 REGEXP_SUBSTR
platform 的默认第一个模式出现:
select regexp_substr(my_column, 'test_(.*)_(.*)_(.*)') as platform from table
获取value 的第二个模式出现:
select regexp_substr(my_column, 'test_(.*)_(.*)_(.*)', 1, 2) as value from table
但是,这不起作用。我哪里错了?
【问题讨论】: