如何在配置单元中提取字符串的一部分

问题描述 投票:1回答:1

我有一列称为desc,它包含以下字符串:

BUY 20 SAVE 5

所需的输出:20

我尝试过:

SELECT
   desc,
   split (desc, 'Y\\s')[1] as Revenue
FROM table1;
sql hadoop hive hql
1个回答
1
投票

使用Hive regexp_extract(string subject, string pattern, int index)功能:

regexp_extract(string subject, string pattern, int index)

请参见以下示例:

© www.soinside.com 2019 - 2024. All rights reserved.