提取两个已知字符串/字符集之间的字符串/字符

时间:2016-09-22 22:02:38

标签: regex hadoop substring toad

我想从一个列(名为= description)

中获取两个已知字符串(“Hostname:”和“Host Alias:”)之间的字符串(服务器名称)

示例数据

  

我们收到了该服务的提醒:xxxxx-iosdoh_free.USERSHostname:pugsxxxxdsbudlp01.eeeHost别名:894.aa

我的查询与正则表达式:(带来空白值)

select regexp_extract(description, 'regex (?<=Hostname:).*?(?=Host Alias:), 1)', 
from tableA 
where number = '554';

My Query with Substring :(带来空白值)

select substring(description, (locate('Hostname: ', description) + 8), (locate('Host Alias:', description) - 1) - (locate('Hostname: ', description) + 8)) as 'Server_Name'
from tableA 
where number = '554';

如果我运行查询以在'我'和'警告'之间搜索字符串=我们收到警报....,然后我确实在结果中找到'收到',因为'我们'和'警告'之前有空格和在他们之后并被视为一个词。

如何用字符串搜索(没有单词)或者如果你有更好的方法来完成我的任务,那将会有所帮助。

0 个答案:

没有答案
相关问题